Repository navigation
Extract legacy store to separate maven modules - #11933
Conversation
f89a56f to
587225b
Compare
f007c19 to
5d48f34
Compare
|
@hmlnarik Isn't |
| import org.keycloak.services.resources.admin.ext.AdminRealmResourceProviderFactory; | ||
| import org.keycloak.services.resources.admin.permissions.AdminPermissionEvaluator; | ||
|
|
||
| public class LdapServerCapabilitiesRealmAdminProvider implements AdminRealmResourceProviderFactory, AdminRealmResourceProvider { |
There was a problem hiding this comment.
Looks like the new AdminRealmResourceProviderFactory indicates a requirement that should be available from the new store? In this case, the possibility to expose information about the store itself as well as perform operations on it (e.g.: test connection).
Is federation/ldap going to be refactored or replaced by the new store in the future? How the AdminRealmResourceProviderFactory is aligned with the new store?
There was a problem hiding this comment.
@pedroigor - federation and ldap will be different with the new store; they would kind of "blend in" like any other map storage. In order to do that, a store can handle credentials and authentication. This is already visible in the refactoring for credentials.
For LDAP, you can validate and change a password for a specific user.
For Kerberos, you'd send down the SPNEGO token to receive a reply how to continue with the authentication or which user it has been mapped to.
There was a problem hiding this comment.
Looks like the new
AdminRealmResourceProviderFactoryindicates a requirement that should be available from the new store? In this case, the possibility to expose information about the store itself as well as perform operations on it (e.g.: test connection).
Yes, this is the case. The store-specific endpoints would implement this interface and would be used by e.g. admin UI, and example could be a reconfiguration of storages or running a migration for a particular store, or testing a password for a particular store configuration just like we had it for LDAP in the legacy store.
This change is broader at the same time: just as storage, any other (optional) feature may now add an admin endpoint for itself inside realm admin REST endpoint which would only be available if the feature is enabled.
mhajas
left a comment
There was a problem hiding this comment.
@hmlnarik @ahus1 Thank you for the PR. Overall, the changes look good, I like the way this is heading.
However, the PR is huge, it is really hard to see what changes are just moving some code from one module to another, and what was added/changed. I think I need another review round and even then I am not sure I would be confident to say there are no issues.
I understand that in this state it is really hard to split the PR, but if you see any option of doing that, I would vote for that.
Anyway, see my comments in the code.
|
@pedroigor Thank you for the review! Kind of level hard for reviewers as well, I admit :-)
It is, both model-infinispan and model-jpa are legacy. Either way would work for me - keeping it as is, or restructuring it - and I have no strong arguments for either. I kept the directory structure untouched in this regard since the modules will eventually disappear anyway, and the map and legacy modules coexist today as well. If the arguments prevail for the latter, would it be possible to do it separately after merging this PR? |
stianst
left a comment
There was a problem hiding this comment.
No objections from me on this one. Although I have NOT reviewed it thoroughly, but happy with the general approach.
Would be great to get a PR to release notes and migration guide prior to merging this one though. One thing I'd like to understand better is how much of a breaking change this is to folks with custom providers.
…l exception to the caller.
…if it was missing
Co-Authored-By: hmlnarik@redhat.com
b78a39c to
e1e2467
Compare
|
LGTM and will approved after open discussion are concluded, and keycloak/keycloak-documentation#1541 has been reviewed and approved by others as well. |
|
Thank you everyone for your reviews and help! |
Description
In preparation for the Storage.X map storage functionality, modules and APIs have been consolidated so that the service layer won't differentiate between cached vs. non-cached, and federated vs. local storage, and legacy storage code is placed into its own modules.
Disclaimer: This PR is big. This is consequence of storage code being spread across many places - moving one class led to moving another etc. The commits are structured in a way that should help reviewing this PR, and it is the reason for intentional breaking the rule of "one commit per PR". The commits will be squashed upon merge.
Modules
Three new modules have been introduced, and data-oriented code from server-spi, server-spi-private, and services has been moved there:
model-legacy- contains all public facing APIs from legacy store, like User Storage APImodel-legacy-private- contains all implementation that relates to user storage management (e.g. storage*Managerclasses.model-legacy-services- contains all REST endpoints that directly operate on legacy store, and have no meaning in the new storeThese modules will be available as long as legacy store would be supported. After that period, they will be removed.
API impact
KeycloakSessionhas been simplified. Several methods have been deprecated inKeycloakSession. Please see Deprecated old KeycloakSession APIs commitKeycloakSession, all methods ending inlocalStorageandstorageManagerare deprecated. Instead of callingsession.userStorageManager(), callsession.users()instead. When code continues to call the deprecated methods, it will be redirected to the new methods. As an example,userLocalStorage()will now return the same result asusers(), which might involve a cache if that has been enabled in the local setup.KeycloakSessioncan be removed in the future without changing any Keycloak code.KeycloakSession.userCredentialManager()is deprecated, user credential API has moved toUserModel.credentialManager(). Credentials for users previously managed viasession.userCredentialManager().method(realm, user, ...)are now managed withuser.credentialManager().method(...)which gets this functionality closer to API of users, and won't require a distinction of where the user data is physically located.New private SPI
org.keycloak.services.resources.admin.ext.AdminRealmResourceSpifor registering endpoints on the realm admin endpoint. Some of the realm endpoints in services were tightly coupled with user storage or LDAP. To avoid the services to depend on the storage and the legacy modules, this SPI has been introduced.user-storage,ldap-server-capabilitiesandtestLDAPConnection.Access to the legacy store
While some APIs have been deprecated and classes moved to other modules, there will still be a period when legacy store will be available in Keycloak. Caution was executed to break this compatibility minimally, and the code using legacy store only needs to depend (directly or indirectly) on
model-map-legacymodule in addition toserver-spi.For example, the existing quickstart example still compiles. Still, those who wrote Keycloak extensions based on the Keycloak user-storage-jpa Quickstart (https://github.com/keycloak/keycloak-quickstarts/tree/main/user-storage-jpa) should review the migration guide to find out about the changed semantics in the deprecated methods especially on
KeycloakSession.session.getProvider(DatastoreProvider.class)toLegacyStoreManagersfor the needed provider directly to obtain the functionality they need while the legacy modules exist. This will be available only if the legacy modules are part of the deployment.org.keycloak.storage.UserStorageProviderSpiin the legacy module that allows access to the old user storage APIs.org.keycloak.services.legacysessionsupport.LegacySessionSupportSpito access the now-deprecated functionality around storage. The only implementation of this lives in a (private) legacy-services module.org.keycloak.storage.UserStorageUtilfor convenience.Export / import
New storage only supports the latest export file representation, it performs no migration
Parts of the import/export functionality has been moved to the legacy module as it depends on the user storage APIs. Work will continue to refactor this so that the service layer will forward a file or
InputStreamto the storage layer without parsing the JSON to a representation. This will remove the need to have fields from older Keycloak versions in the REST representations in the service layer.Out of scope of this PR / Future work
Completing the change of the export / import flow so that the datastore can directly perform updates rather than converting representation to model and back to datastore representation. This will allow sharing no-downtime capabilities of a store with that of export / import functionality, e.g. by leveraging future YAML static store directly as an export format.
Fixes: #10279
Fixes: #10281