-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Avoid using UserCredentialManager from user storage extensions #43695
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
Conversation
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.
Unreported flaky test detected, please review
Unreported flaky test detectedIf the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR. org.keycloak.testsuite.federation.ldap.LDAPProvidersIntegrationTest#updateLDAPUsernameTest |
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.
For 27, my proposal would be:
- Rename
org.keycloak.credential.UserCredentialManagertoorg.keycloak.credential.DefaultUserCredentialManager(and make it private as you are proposing) - Rename
org.keycloak.models.SubjectCredentialManagertoorg.keycloak.models.UserCredentialManager
| * | ||
| * @return user credential manager | ||
| */ | ||
| SubjectCredentialManager getUserCredentialManager(UserModel user); |
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.
Is it the best place to have this method? It seems a bit weird that we now have this:
session.users()
and:
session.getUserCredentialManager()
Instead of something like this:
session.users().getCredentialManager(user)
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.
That should work as well.
Was thinking about this and originally did not used this just because we have multiple implementations of UserProvider and the jpa/infinispan implementations are more towards to have mostly logic related to CRUD of particular storage (EG. JpaUserProvider has mostly methods related to CRUD of users to the DB). At the same time, introducing the method to KeycloakSession is also not great... So I've updated to use the approach you suggest.
closes keycloak#43694 Signed-off-by: mposolda <[email protected]>
Signed-off-by: mposolda <[email protected]>
This works. Considering this, I wonder that it is possible to introduce already class in their |
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.
Unreported flaky test detected, please review
Unreported flaky test detectedIf the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR. org.keycloak.testsuite.forms.AuthenticatorSubflowsTest2#testSubflow2Keycloak CI - Forms IT (chrome) |
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.
Unreported flaky test detected, please review
Unreported flaky test detectedIf the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR. org.keycloak.testsuite.forms.AuthenticatorSubflowsTest2#testSubflow2Keycloak CI - Forms IT (chrome) |
|
@pedroigor Thanks! |
closes #43694
There is an issue #43626 for make sure
keycloak-model-storagedoes not have dependency onkeycloak-server-spi-private.In the PR for that issue, I took the approach of moving
UserCredentialManagerto thekeycloak-server-spi-private. But this means that people cannot use theUserCredentialManagerfrom their user-storage providers anymore (due the fact that if they use it, they will need dependency onkeycloak-server-spi-private). However this might be a backwards incompatible change as people may already useUserCredentialManagerin their providers similarly like for example our quickstart is doing: https://github.com/keycloak/keycloak-quickstarts/blob/main/extension/user-storage-simple/src/main/java/org/keycloak/quickstart/readonly/PropertyFileUserStorageProvider.java#L88 .So was thinking about doing this in multiple steps:
new UserCredentialManager()is not recommended for the use, so people have a chance to migrate to avoid using this class directly, but rather access it via the method onKeycloakSessionUserCredentialManagertokeycloak-server-spi-privateand make sure thatkeycloak-model-storagecan remove the dependency onkeycloak-server-spi-private(will require few other minor things done in .The alternative approach is to keep
UserCredentialManagerinkeycloak-model-storage, but this does not seem right to me TBH as this class contains lots of logic, which does not need to be directly accessible to people in their applications. Among other things, it would also require moving few other classes (likeDatastoreProviderfor example) tokeycloak-server-spiorkeycloak-model-storageand it would mean that people will need to declare dependency on opentelemetry in their user-storage providers (asUserCredentialManageris using opentelemetry). But I can revisit if you think this would be better?What do you think?