Avoid using UserCredentialManager from user storage extensions #43695
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.
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?