MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / checkUserAPIReadOnlyFields

Function checkUserAPIReadOnlyFields

rest/admin_api.go:2382–2404  ·  view source on GitHub ↗

checkUserAPIReadOnlyFields will return true if read only user fields are unchanged, else false. If a read only field is unchanged it will nil the field so the update to principle ignores it.

(newInfo auth.PrincipalConfig, user auth.User)

Source from the content-addressed store, hash-verified

2380// checkUserAPIReadOnlyFields will return true if read only user fields are unchanged, else false. If a read only field
2381// is unchanged it will nil the field so the update to principle ignores it.
2382func checkUserAPIReadOnlyFields(newInfo auth.PrincipalConfig, user auth.User) (auth.PrincipalConfig, bool) {
2383 if newInfo.JWTIssuer != nil {
2384 if *newInfo.JWTIssuer != user.JWTIssuer() {
2385 return newInfo, false
2386 }
2387 newInfo.JWTIssuer = nil
2388 }
2389 if len(newInfo.JWTRoles) > 0 {
2390 userJWTRoles := user.JWTRoles().AsSet()
2391 if !newInfo.JWTRoles.Equals(userJWTRoles) {
2392 return newInfo, false
2393 }
2394 newInfo.JWTRoles = nil
2395 }
2396 if len(newInfo.JWTChannels) > 0 {
2397 userJWTChan := user.JWTChannels().AsSet()
2398 if !newInfo.JWTChannels.Equals(userJWTChan) {
2399 return newInfo, false
2400 }
2401 newInfo.JWTChannels = nil
2402 }
2403 return newInfo, true
2404}
2405
2406// auditDbAuditEnabled writes any audit events for changes in whether db auditing is enabled
2407func auditDbAuditEnabled(ctx context.Context, dbName string, previousEnabled, newEnabled bool, events []uint) {

Callers 1

updatePrincipalMethod · 0.85

Calls 5

AsSetMethod · 0.80
JWTIssuerMethod · 0.65
JWTRolesMethod · 0.65
JWTChannelsMethod · 0.65
EqualsMethod · 0.45

Tested by

no test coverage detected