-
Notifications
You must be signed in to change notification settings - Fork 56
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
maintain: track provider groups separate from users #3211
Conversation
internal/access/identity.go
Outdated
@@ -170,10 +170,6 @@ func UpdateIdentityInfoFromProvider(c RequestContext, oidc providers.OIDCClient) | |||
logging.Errorf("failed to revoke invalid user session: %s", nestedErr) | |||
} | |||
|
|||
if nestedErr := data.DeleteProviderUsers(db, data.ByIdentityID(identity.ID), data.ByProviderID(provider.ID)); nestedErr != 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.
Removed this, on a failure the access is revoked, but we don't know that the user no longer exists. Its confusing when their group membership changes based on a failed login.
internal/server/authn/oidc.go
Outdated
@@ -45,7 +45,7 @@ func (a *oidcAuthn) Authenticate(ctx context.Context, db data.GormTxn, requested | |||
return AuthenticatedIdentity{}, fmt.Errorf("exhange code for tokens: %w", err) | |||
} | |||
|
|||
identity, err := data.GetIdentity(db, data.Preload("Groups"), data.ByName(email)) |
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.
The identity groups loaded here weren't used
201f914
to
84ede6c
Compare
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.
Nice! I haven't looked over all of it yet, but left a couple suggestions/questions on the model and diagram
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.
I think we've really complicated things here and the complication isn't worth it. I really hate that the queries now have to query provider tables to build the picture of what our memberships are.
075a543
to
3b54829
Compare
351825a
to
f0caaa5
Compare
ccda0f6
to
039a590
Compare
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.
I think we can do more to simplify this. There's no reason to keep two active join tables for membership; the provider memberships should update our memberships which simplifies querying and joining a ton; it's a lot easier if our core application knows nothing about providers and provider groups
de5eb79
to
12233c6
Compare
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.
I think this is looking good! I was surprised that identities_groups
was still around after these changes. I left a question about that below.
I'll continue to review tomorrow.
0ca65a1
to
903edb6
Compare
142c922
to
ddf3318
Compare
@@ -101,7 +102,7 @@ func DeleteGroup(tx WriteTxn, id uid.ID) error { | |||
|
|||
_, err = tx.Exec(`DELETE from identities_groups WHERE group_id = ?`, id) |
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.
I think this has a similar problem to users; If you're deleting a group that was both created by infra and also the result of a mapping, what happens to that mapping? do you leave the group and only remove the identities_groups record for the infra provider?
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.
Yeah, this would result in the group being deleted, and then just re-created next time a user in a provider with that group is synchronized. That's what would happen at the moment too, so I think the fix for this is in our group mapping UI which will come after this.
if opts.ByMemberIdentityID != 0 { | ||
query.B(` | ||
JOIN provider_groups_provider_users | ||
ON provider_groups.name = provider_groups_provider_users.provider_group_name |
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.
should it join on id instead? names could be problematic if they're not indexed
399963b
to
56386e2
Compare
- join group membership from provider group relation - unlink provider groups from groups on deletion - migrate provider user groups to provider groups
56386e2
to
b89e82d
Compare
Summary
In order to track where users had their groups assigned to them more accurately updating the database schema to track and resolve group membership. This means tracking the state of external identity provider groups with relations to their provider users, and adding provider information to identities_groups relations.
identities_groups
relations now have the form (identity_id, group_id, provider_id, provider_group_name) to allow mapping external groups from identity providers to groups within Infra. This behavior will be a later change, this PR keeps the same behavior of automatically mapping groups from identity providers to groups within Infra that have the same name.Checklist
Related Issues
Resolves #3138
Resolves #2982