Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

mposolda
Copy link
Contributor

@mposolda mposolda commented Oct 21, 2025

…storage

closes #43626

The aim is to remove dependency on keycloak-server-spi-private from the keycloak-model-storage module, so that people don't need to use keycloak-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 the keycloak-server-spi . Also ExecutorProvider and it's factory. Those are simple utility class and I don't see issues with moving.

  • Moved UserCredentialManager from keycloak-model-storage to keycloak-server-spi-private . This class is referenced from AbstractUserAdapterFederatedStorage, 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 method getUserCredentialManager to KeycloakSession .

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 on KeycloakSession are:

  1. Add some utility method (for example to UserStorageUtil), which will use reflection to reference UserCredentialManager. The AbstractUserAdapterFederatedStorage can call then this utility method.

  2. Convert SubjectCredentialManager to be the Provider and create some provider factory and SPI for it. Then AbstractUserAdapterFederatedStorage could use something like return session.getProvider(SubjectCredentialManager.class); .

  3. Keep UserCredentialManager in the keycloak-model-storage. This would require some more dependencies to be declared in keycloak-model-storage (like opentelemetry and it's dependencies) and much more changes (EG. moving DatastoreProvider to keycloak-model-storage etc).

  4. Any better alternative?

Another side-effect of moving UserCredentialManager is that keycloak-model-storage is now dependency of keycloak-server-spi-private (as UserCredentialManager has some more references on some classes from keycloak-model-storage). I don't see any issue with that one.

@mposolda mposolda self-assigned this Oct 21, 2025
Copy link
Contributor

@rmartinc rmartinc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM @mposolda! It's not a big change in the end. The only thing is the getUserCredentialManager addition is in the server-spi, is that a problem? (I don't expect anyone implementing its own session but...)

@mposolda
Copy link
Contributor Author

LGTM @mposolda! It's not a big change in the end. The only thing is the getUserCredentialManager addition is in the server-spi, is that a problem? (I don't expect anyone implementing its own session but...)

Yes, I also don't expect this to be a problem. I think we are not expecting people to implement their own instances of things like KeycloakSession , RealmModel (or any other models) or similar? As otherwise we would not be able to add any new methods there.

IMO adding new method is fine, but updating/removing signature of existing methods is problematic as people may already invoke existing methods from their providers.

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.

Remove dependency on keycloak-server-spi-private from keycloak-model-storage

2 participants