Skip to content

Conversation

@captainbeardo
Copy link
Contributor

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

  1. How was this tested:

Unit test and manual test of SCIM user

@captainbeardo captainbeardo requested a review from a team as a code owner March 5, 2025 21:05
@shakeelrao
Copy link
Contributor

shakeelrao commented Mar 20, 2025

does this need to be exposed via tcld? curious what the use-case is (i'm assuming SCIM users always have an unspecified account role).

also: reminder to test the locally built tcld against staging.


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 {
Copy link
Contributor

@shakeelrao shakeelrao Mar 20, 2025

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.

Copy link
Contributor Author

@captainbeardo captainbeardo Apr 30, 2025

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 {
Copy link
Contributor

@shakeelrao shakeelrao Mar 20, 2025

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.

Copy link
Contributor Author

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.

@captainbeardo
Copy link
Contributor Author

does this need to be exposed via tcld? curious what the use-case is (i'm assuming SCIM users always have an unspecified account role).

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)
Copy link
Member

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())

Copy link
Contributor Author

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
Copy link
Member

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?

Copy link
Member

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?

Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants