-
Notifications
You must be signed in to change notification settings - Fork 22
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -146,7 +146,7 @@ func (c *UserClient) inviteUsers( | |
| var roleIDs []string | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
|
||
| // first get the required account role | ||
| role, err := getAccountRole(c.ctx, c.client, accountRole) | ||
| role, err := getAccountRole(c.ctx, c.client, accountRole, false) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would this throw a nil pointer exception below?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
@@ -257,11 +257,21 @@ func (c *UserClient) setAccountRole( | |
| return err | ||
| } | ||
| var newRoleIDs []string | ||
| accountRoleToSet, err := getAccountRole(c.ctx, c.client, accountRole) | ||
| accountRoleToSet, err := getAccountRole(c.ctx, c.client, accountRole, true) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| if accountRoleToSet.Spec.AccountRole.ActionGroup == auth.ACCOUNT_ACTION_GROUP_ADMIN { | ||
| if accountRoleToSet == nil { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if possible, i'd recommend having also: do we need this additional
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly, |
||
| // Setting account role to none. | ||
| for _, r := range userRoles { | ||
| // remove any account roles | ||
| if r.Type == auth.ROLE_TYPE_PREDEFINED && r.Spec.AccountRole != nil { | ||
| continue | ||
| } else { | ||
| newRoleIDs = append(newRoleIDs, r.Id) | ||
| } | ||
| } | ||
| } else if accountRoleToSet.Spec.AccountRole.ActionGroup == auth.ACCOUNT_ACTION_GROUP_ADMIN { | ||
| // set the user account admin role | ||
| y, err := ConfirmPrompt(ctx, "Setting admin role on user. All existing namespace permissions will be replaced, please confirm") | ||
| if err != nil { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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->allowUnspecifiedand remain consistent to with the enum definition.Uh oh!
There was an error while loading. Please reload this page.
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.
noneis just the parameter used to indicate that no roles should be specified.