Skip to content
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

feat: allow deletion of an individual OIDC credential #3968

Merged
merged 3 commits into from
Jun 25, 2024

Conversation

alnr
Copy link
Contributor

@alnr alnr commented Jun 24, 2024

This extends the existing DELETE /admin/identities/{id}/credentials/{type} API to accept an ?identifier=foobar query parameter for {type}==oidc like such:

DELETE /admin/identities/{id}/credentials/oidc?identifier=github%3A012345

This will delete the GitHub OIDC credential with the identifier github:012345 (012345 is the subject as returned by GitHub).

To find out which OIDC credentials exist, call GET /admin/identities/{id}?include_credential=oidc beforehand.

This will allow you to delete individual OIDC credentials for users even if they have several set up.

@alnr alnr self-assigned this Jun 24, 2024
@alnr alnr requested review from aeneasr, zepatrik and hperl as code owners June 24, 2024 09:29
@@ -507,6 +507,80 @@ func (i *Identity) WithDeclassifiedCredentials(ctx context.Context, c cipher.Pro
return &ii, nil
}

func (i *Identity) deleteCredentialWebAuthFromIdentity() error {
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 function was moved here from identity/handler.go where it had the signature func deletCredentialWebAuthFromIdentity(identity *Identity) (*Identity, error)

Copy link

codecov bot commented Jun 24, 2024

Codecov Report

Attention: Patch coverage is 74.54545% with 14 lines in your changes missing coverage. Please review.

Project coverage is 78.19%. Comparing base (af5ea35) to head (0ee8dea).

Files Patch % Lines
identity/identity.go 79.16% 5 Missing and 5 partials ⚠️
identity/handler.go 42.85% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3968      +/-   ##
==========================================
- Coverage   78.21%   78.19%   -0.03%     
==========================================
  Files         363      363              
  Lines       25486    25516      +30     
==========================================
+ Hits        19935    19953      +18     
- Misses       4030     4038       +8     
- Partials     1521     1525       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@aeneasr aeneasr left a comment

Choose a reason for hiding this comment

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

This is looking great already!

What I'm most worried about is that we accidentally delete the wrong credential. While it doesn't appear to be the case from reading the code, I think it would be good to have test(s) that verify that.

To make it a bit easier to test, you can probably set up a unit test for the new identity methods?

@alnr
Copy link
Contributor Author

alnr commented Jun 24, 2024

I've added a test TestDeleteCredentialOIDCFromIdentity. The handler test is also quite comprehensive.

@aeneasr aeneasr merged commit a43cef2 into master Jun 25, 2024
28 of 29 checks passed
@aeneasr aeneasr deleted the alnr/delete-credential-identifier branch June 25, 2024 09:21
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.

2 participants