(field string, claims jwt.MapClaims)
| 261 | } |
| 262 | |
| 263 | func (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 | |
| 282 | type RoleSyncSettings codersdk.RoleSyncSettings |
| 283 |
no test coverage detected