Move CreateProviderUser into credential operations#3141
Merged
Conversation
07d88eb to
916ca6d
Compare
dnephin
commented
Sep 6, 2022
|
|
||
| // if the request is from an admin, the infra user may not exist yet, so create the | ||
| // provider_user if it's missing. | ||
| _, _ = data.CreateProviderUser(rCtx.DBTxn, data.InfraProvider(rCtx.DBTxn), user) |
Contributor
Author
There was a problem hiding this comment.
We ignored the error here previously. It's probably ok, but I wonder if we should handle it for consistency. The data.CreateProviderUser function already returns no error if the entry already exists.
By moving the creation of the provider user into the credential operations we can remove the need for this extra access function
BruceMacD
approved these changes
Sep 7, 2022
Collaborator
BruceMacD
left a comment
There was a problem hiding this comment.
thanks for cleaning this up
916ca6d to
79ef082
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
While working on another change I noticed this
access.CreateProviderUserfunction. Unlike most of the otheraccessfunctions this is not a function that performs authorization for an API operation. It's a helper function for creating the necessary join table when an admin performs an operation that creates an infra user (either by creating a new user, or giving an IDP user a password).By moving this create-if-not-exists into the
CreateCredentialandUpdateCredentialfunctions we remove the need for thisaccessfunction, and we make the{Create,Update}Credentialfunctions safer (because other callers will no longer need to perform this operation).data.CreateProviderUseralready checks for an existing user, so it's safe to call in any case. We should probably rename that function as it behaves differently from otherCreatefunctions in thedatapackage, but i've left that rename for a different time. I'm also not sure what the new name should be.