-
Notifications
You must be signed in to change notification settings - Fork 109
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
Bed-4852: SSO Provider Delete Endpoint #890
Conversation
…ble to allow for easy cascade on delete. Added audit logging to deleting sso_providers
…place of DeleteSSOProvider
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 there's just a smidge more cleanup and then we 🚀
…of letting the PG contraint to remove references
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.
Tested locally and hit a few small snags! Otherwise looks solid, love the cleanup ❤️
|
||
-- Set the user's saml_provider_id to null when an sso_provider or saml_provider is deleted | ||
ALTER TABLE ONLY users | ||
DROP CONSTRAINT fk_users_saml_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.
DROP CONSTRAINT fk_users_saml_provider; | |
DROP CONSTRAINT IF EXISTS fk_users_saml_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.
Looks good, feels good, tests good; Send it! 🚀
cmd/api/src/api/v2/auth/sso.go
Outdated
} else if err = s.db.DeleteSSOProvider(request.Context(), ssoProviderID); errors.Is(err, database.ErrNotFound) { | ||
api.WriteErrorResponse(request.Context(), api.BuildErrorResponse(http.StatusNotFound, err.Error(), request), response) | ||
} else if err != 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.
} else if err = s.db.DeleteSSOProvider(request.Context(), ssoProviderID); errors.Is(err, database.ErrNotFound) { | |
api.WriteErrorResponse(request.Context(), api.BuildErrorResponse(http.StatusNotFound, err.Error(), request), response) | |
} else if err != nil { | |
} else if err = s.db.DeleteSSOProvider(request.Context(), ssoProviderID); err != nil { |
Description
Add a new endpoint to delete SSO Providers
Motivation and Context
This PR addresses: BED-4852
Adds the ability for admins to delete SSO Providers and any associated references to them
How Has This Been Tested?
Basic Test
I setup my database as followed:
Sent a request to
/api/v2/sso-providers/{sso_provider_id}
And received a 200 response back
Refreshing the tables in the database shows that the references were properly nulled out
Attempting to delete a non-existent sso provider:
Attempting to delete a SAML provider after replacing DeleteSAMLProvider with the DeleteSSOProvider method
After sending the request:
And the audit log with details:
Screenshots (optional):
Types of changes
Checklist: