-
Notifications
You must be signed in to change notification settings - Fork 23
feat: allow account role to be set to none #431
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
base: main
Are you sure you want to change the base?
Conversation
|
does this need to be exposed via also: reminder to test the locally built |
|
|
||
| func getAccountRole(ctx context.Context, client authservice.AuthServiceClient, actionGroup string) (*auth.Role, error) { | ||
| func getAccountRole(ctx context.Context, client authservice.AuthServiceClient, actionGroup string, allowNone bool) (*auth.Role, error) { | ||
| if allowNone && strings.ToLower(strings.TrimSpace(actionGroup)) == accountActionGroupNone { |
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.
suggestion: i'd rename the allowNone -> allowUnspecified and remain consistent to with the enum definition.
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.
Unspecified is different than none. In this case the user should have no actual account role, it's not that they have an account role of unspecified. none is just the parameter used to indicate that no roles should be specified.
| return err | ||
| } | ||
| if accountRoleToSet.Spec.AccountRole.ActionGroup == auth.ACCOUNT_ACTION_GROUP_ADMIN { | ||
| if accountRoleToSet == nil { |
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.
if possible, i'd recommend having getAccountRole return auth.ACCOUNT_ACTION_GROUP_UNSPECIFIED instead of nil.
also: do we need this additional if branch? seems like we can use the existing else branch and skip appending the accountRoleToSet if the account action group is UNSPECIFIED.
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.
Similarly, UNSPECIFIED is a valid value in the enum. none exists because it shouldn't have any roles.
This is specifically to allow users who existed before SCIM and have an account role to be removed from their roles so that they are like new SCIM users. |
|
|
||
| // first get the required account role | ||
| role, err := getAccountRole(c.ctx, c.client, accountRole) | ||
| role, err := getAccountRole(c.ctx, c.client, accountRole, false) |
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.
would this throw a nil pointer exception below?
roleIDs = append(roleIDs, role.GetId())
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 doesn't allow nil to be returned because none is invalid for inviting a user. It'd get an error.
| } | ||
|
|
||
| // the role ids to invite the users for | ||
| var roleIDs []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.
just so i understand--we are allowing a state where we can set account role to nil--and namespace roles to not nil?
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.
Also do we need to update the access package validation to allow the account role to be empty?
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.
Yes, account role can be nil, and namespace roles can be empty or not empty.
The access validation already supports no account role if the user is a SCIM user.
What was changed
If a user was added via SCIM, setting their account role to none is valid. The call will fail if the user is not a SCIM user.
Why?
So user's can have only group derived roles assignments.
Checklist
Unit test and manual test of SCIM user