Skip to content

fix: delete users from specific identity provider#3398

Merged
BruceMacD merged 5 commits intomainfrom
brucemacd/delete_identity_tracking
Oct 11, 2022
Merged

fix: delete users from specific identity provider#3398
BruceMacD merged 5 commits intomainfrom
brucemacd/delete_identity_tracking

Conversation

@BruceMacD
Copy link
Collaborator

@BruceMacD BruceMacD commented Oct 5, 2022

  • infra users command adds/removes from the infra identity provider specifically
  • consolidate identity deletion logic
  • delete identity when it no longer exists in any identity provider

Summary

When a user is deleted using infra users add or infra users rm only delete the resources associated with the identity through the Infra provider. Users from other identity providers can be removed by removing the associated provider, or through SCIM (soon).

Checklist

  • Wrote appropriate unit tests
  • Considered security implications of the change
  • Updated associated configuration where necessary
  • Change is backwards compatible if it needs to be (user can upgrade without manual steps?)
  • Nothing sensitive logged
  • Considered data migrations for smooth upgrades

Related Issues

Resolves #3397
Resolves #2838

- infra users command adds/removes from the infra identity provider specifically
- consolidate identity deletion logic
- delete identity when it no longer exists in any identity provider
Copy link
Contributor

@dnephin dnephin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! I think this will resolves a couple problems.

There are a lot of calls to DeleteIdentity so I think I'll need another pass to think through all those scenarios and see how it matches up to our test coverage. Left a few questions from my first pass.

return nil, err
}

_, err = data.CreateProviderUser(db, data.InfraProvider(db), identity)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at where we call CreateProviderUser, it seems like the majority of the time it's either accompanied by CreateCredential, or by CreateIdentity.

I wonder if we should have CreateCredential call this automatically for us (since a credential doesn't work without this record, and the call is idempontent), and add a CreateInfraUser that creates both the identity and provider_user.

Probably not for this PR, but it's something I've been wondering for a bit now. Maybe that'll make it easier to ensure that tests correctly reflect production without having to remember to call both.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CreateCredential creating the provider user would make a lot of sense, but the limitation there at the moment is that user can be declared in grants without having a credential linked to them.

Ex:

infra grants add dne@example.com infra --role admin --force
Created user "dne@example.com"
Created grant to "infra" for "dne@example.com"

- do not delete credential when identity is not deleted from infra provider
- test credential not deleted in infra provider
- assert provider user is deleted in test
@BruceMacD BruceMacD requested a review from hoyyeva as a code owner October 7, 2022 18:53
Copy link
Contributor

@dnephin dnephin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DeleteIdentities does a lot of things, and I think we might be missing assertions for the conditional removal of grants and groups. With that test coverage I think this looks great!

Should access.UpdateIdentityInfoFromProvider be calling data.DeleteIdentities now to clean up? It's currently only deleting the access key and provider_user, but I would expect it to need to do more if that was the last provider.

@BruceMacD BruceMacD enabled auto-merge (squash) October 11, 2022 15:05
@BruceMacD BruceMacD merged commit 234de56 into main Oct 11, 2022
@BruceMacD BruceMacD deleted the brucemacd/delete_identity_tracking branch October 11, 2022 15:08
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.

When an identity is soft-deleted provider user records should be removed Consolidate duplicate code paths for deleting users

2 participants