Remove dependency on keycloak-server-spi-private from keycloak-model-… #43627
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.
…storage
closes #43626
The aim is to remove dependency on
keycloak-server-spi-private
from thekeycloak-model-storage
module, so that people don't need to usekeycloak-server-spi-private
from their own user-storage extensions.If the approach is OK, I can add also a note to the release-notes or upgrading-guide regarding this change.
Details of the PR
Moved
UserModelDefaultMethods
to thekeycloak-server-spi
. AlsoExecutorProvider
and it's factory. Those are simple utility class and I don't see issues with moving.Moved
UserCredentialManager
fromkeycloak-model-storage
tokeycloak-server-spi-private
. This class is referenced fromAbstractUserAdapterFederatedStorage
, which is referenced from our docs and is supposed to be used in Keycloak user extensions. To remove the reference from the class, I've added new methodgetUserCredentialManager
toKeycloakSession
.I am not so happy with adding new method on
KeycloakSession
, but not sure about better approach? Some alternative approaches, which may not require any changes onKeycloakSession
are:Add some utility method (for example to
UserStorageUtil
), which will use reflection to referenceUserCredentialManager
. TheAbstractUserAdapterFederatedStorage
can call then this utility method.Convert
SubjectCredentialManager
to be theProvider
and create some provider factory and SPI for it. ThenAbstractUserAdapterFederatedStorage
could use something likereturn session.getProvider(SubjectCredentialManager.class);
.Keep
UserCredentialManager
in thekeycloak-model-storage
. This would require some more dependencies to be declared inkeycloak-model-storage
(likeopentelemetry
and it's dependencies) and much more changes (EG. movingDatastoreProvider
tokeycloak-model-storage
etc).Any better alternative?
Another side-effect of moving
UserCredentialManager
is thatkeycloak-model-storage
is now dependency ofkeycloak-server-spi-private
(asUserCredentialManager
has some more references on some classes fromkeycloak-model-storage
). I don't see any issue with that one.