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

[BACK-2785] Add keycloak extension endpoint to extract and create a new custodian user from a fake child account. #28

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

lostlevels
Copy link
Contributor

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.

@lostlevels lostlevels changed the title [BACK-2785] Add keycloak extension endpoint to clone a user. [BACK-2785] Add keycloak extension endpoint to extract and create a new custodian user from a fake child account. Apr 24, 2024
// 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";
Copy link
Collaborator

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?

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();
Copy link
Collaborator

@toddkazakov toddkazakov Apr 25, 2024

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);
Copy link
Collaborator

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

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.

3 participants