-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
[BACK-2785] Add keycloak extension endpoint to extract and create a new custodian user from a fake child account. #28
base: master
Are you sure you want to change the base?
Conversation
admin/src/main/java/org/tidepool/keycloak/extensions/resource/CloneUserBody.java
Outdated
Show resolved
Hide resolved
admin/src/main/java/org/tidepool/keycloak/extensions/resource/TidepoolAdminResource.java
Outdated
Show resolved
Hide resolved
admin/src/main/java/org/tidepool/keycloak/extensions/resource/TidepoolAdminResource.java
Outdated
Show resolved
Hide resolved
admin/src/main/java/org/tidepool/keycloak/extensions/resource/TidepoolAdminResource.java
Outdated
Show resolved
Hide resolved
admin/src/main/java/org/tidepool/keycloak/extensions/resource/CloneUserBody.java
Outdated
Show resolved
Hide resolved
// CUSTODIAN_ROLE is the role to give custodians accounts extracted from | ||
// profiles that contain a fake child. | ||
// TODO: decide on actual role | ||
private static final String CUSTODIAN_ROLE = "custodian"; |
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 suggest using care_partner. @ewollesen thoughts?
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.
While I think a custodian is a care_partner, I'm not sure that a care_partner is a custodian.
Custodian implies more access and responsbility.
So migrating these roles to care_partner is OK, but we need to be sure we don't accidentally equate care_partner with custodian in other ways.
if (user == null) { | ||
throw new NotFoundException("User not found."); | ||
} | ||
boolean alreadyMigrated = user.getUsername() != null && TidepoolAdminResource.UNCLAIMED_CUSTODIAL.matcher(user.getUsername()).find(); |
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 suggest keeping a ref to the userId of custodiaN in the custodiaL (child) profile in case something goes wrong.
// The Keycloak 24+ modules have removed cache eviction methods, so instead set child user's email and username "again" through the model. If we got this far, | ||
// the previous transaction has succeeded so this is "safe" and will cause a user updated event which will clear the cache entry for the given user. | ||
user.setEmail(newUsername); | ||
user.setUsername(newUsername); |
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.
You should add custodial_account role
3f790d1
to
6586868
Compare
child with a new username and email and giving the newly created parent the child's previous username and email along w/ all other properties.
and have a separate EntityManager per transaction.
…e it if it's already in that format.
1d207ed
to
71f3966
Compare
Used for migrating fake child accounts.
Creates a new "parent" user with email of target "child" account, copying over most fields, except a few custodiaL attributes. Parent will assume the email and username of the child, and the child will be given a new username and email as part of the request body.