MCPcopy Index your code
hub / github.com/coder/coder / RolesFromClaim

Method RolesFromClaim

coderd/idpsync/role.go:263–280  ·  view source on GitHub ↗
(field string, claims jwt.MapClaims)

Source from the content-addressed store, hash-verified

261}
262
263func (AGPLIDPSync) RolesFromClaim(field string, claims jwt.MapClaims) ([]string, error) {
264 rolesRow, ok := claims[field]
265 if !ok {
266 // If no claim is provided than we can assume the user is just
267 // a member. This is because there is no way to tell the difference
268 // between []string{} and nil for OIDC claims. IDPs omit claims
269 // if they are empty ([]string{}).
270 // Use []interface{}{} so the next typecast works.
271 rolesRow = []interface{}{}
272 }
273
274 parsedRoles, err := ParseStringSliceClaim(rolesRow)
275 if err != nil {
276 return nil, xerrors.Errorf("failed to parse roles from claim: %w", err)
277 }
278
279 return parsedRoles, nil
280}
281
282type RoleSyncSettings codersdk.RoleSyncSettings
283

Callers 2

SyncRolesMethod · 0.95
ParseRoleClaimsMethod · 0.80

Calls 2

ParseStringSliceClaimFunction · 0.85
ErrorfMethod · 0.45

Tested by

no test coverage detected