-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CBG-4047: User and role audit events #6962
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just a suggestion to avoid multiple iterations when building a slice of channels from a timed set.
rest/admin_api.go
Outdated
if user != nil { | ||
base.Audit(h.ctx(), base.AuditIDUserUpdate, base.AuditFields{ | ||
"username": internalName, | ||
"roles": user.ExplicitRoles().AsSet().ToArray(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ExplicitRoles().AllKeys() can be used here to avoid going TimedSet->Slice->Set->Slice.
rest/admin_api.go
Outdated
h.writeStatus(http.StatusCreated, "Created") | ||
} | ||
return nil | ||
} | ||
|
||
func getAuditEventAccess(db *db.Database, princ auth.Principal) map[string]map[string][]string { | ||
auditEventAccess := make(map[string]map[string][]string) | ||
collectionAccess := make(map[string][]string) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be moved inside the db.OnlyDefaultCollection() check.
auth/auth.go
Outdated
for scopeName, scope := range collAccess { | ||
explicitChans := make(map[string][]string) | ||
for collectionName, collection := range scope { | ||
explicitChans[collectionName] = collection.ExplicitChannels().AsSet().ToArray() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as elsewhere about ExplicitChannels().AllKeys().
…yDefaultColection check
CBG-4047
Pre-review checklist
fmt.Print
,log.Print
, ...)base.UD(docID)
,base.MD(dbName)
)docs/api
Integration Tests
GSI=true,xattrs=true
https://jenkins.sgwdev.com/job/SyncGateway-Integration/2580/