Replies: 7 comments 3 replies
-
|
Some second thoughts: storing the realm in the key might work when the element was retrieved from the LDAP store before. It might cause problems in a tree store scenario, when the key would be the same for all stores in the tree (I assume), and different stores want to store different additional information in the key. |
Beta Was this translation helpful? Give feedback.
-
|
A similar problem exists on how to find the client when a client role is retrieved by ID. |
Beta Was this translation helpful? Give feedback.
-
|
The realm data should be strictly separated in a storage for safety reasons. Realm in LDAP view probably best resembles a dc or ou. Hence it should not be part of the user ID. The question is very valid though: we need to obtain the realm upon query. Let's first follow this path:
There is a case though when this won't work is when a user is logged in the admin realm and administering other realms. In that case, the realm from the context would be the admin realm rather than the one being edited. Hence the operations within Hence we need a step back. Facts:
For the initial implementation, let's stick only with a single predefined realm. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for reviewing this.
I think this is too restrictive. From an admin's point of view there is no reason to restrict a Keycloak instance to one LDAP server IMHO. Each realm could connect to a separate LDAP server. This is also the case for the current Keycloak configuration, where an admin configures federation on a realm level with connection parameters. An option could be to iterate over all available realms, and return the data found in the first matching realm with GUID + search base DN. Still I would like to discard this option as this is slow an increases with the number of connected LDAP realms. The edge cases are also non-trivial: this would require GUIDs to be different across LDAPs, and connecting to one LDAP from multiple realms that the search base DNs are disjunctive. The latter might be determined at runtime. Different GUIDs across LDAPs sounds easy for a start up until the point where someone starts to clone an LDAP for a test setup :-( I'll also open a new discussion on whether to use the GUID or the DN as the ID. We briefly touched on this in #10076. Once I created the first role in LDAP via Keycloak yesterday, this presented some downsides for GUID. Regarding "The realm data should be strictly separated in a storage for safety reasons [...] Hence it should not be part of the user ID.": We could encrypt the ID used in the storage to make it opaque. [yes, and there are downsides for that: getting encryption right, performance, size of ID] For now, I'll then hard code it to "master", and keep this discussion open to find a real solution. |
Beta Was this translation helpful? Give feedback.
-
|
Earlier today we discussed in the storage team that the realmId could be added by the MapRoleProvider if the store can't determine it itself when calling getRoleById(). As an alternative, using a criteria query was discussed as a possible solution. This might make the query possibly slower, but would provide the additional information to the store as part of the query. A draft code example of the to-be code (between START/END) from ModelRoleProvider: |
Beta Was this translation helpful? Give feedback.
-
|
This has now been resolved as follows / cc: @hmlnarik, @mhajas
A previous attempt to use a modified MapModelCriteriaBuilder to search entities in the transaction and ignoring the realmId was discarded as this results in returning entities from read(query) without a realmId that would then need to be wrapped. |
Beta Was this translation helpful? Give feedback.
-
|
Another update after a new discussion with @hmlnarik / cc: @mhajas The LdapRoleMap transaction will return all its entities without a realmId, both for read(key) and read(query). This enables then caching and invalidation in the caching layer above on entities. Backfilling the realmIds would break that, and make even things inconsistent with caching. This would then require MapRoleAdapter to use the values returned here without a realmId in all places. A first thought has been to wrap all entities returned. Looking deeper the MapRoleAdapter doesn't use the realmId, therefore no envelope is needed. All tests in RoleModelTest pass without an envelop and just an adjusted condition in getRoleById(). A manual test to login to the frontend passes as well. This is part of commit 6d1517b23b6dc371f96d2d2c348de91ad5eb218f |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Problem statement
Map Storage currently retrieves entities by ID using
read(String key)An LDAP Map store will have separate LDAP directories based on the realm being queried. The realm is not part of the signature.
Therefore the LDAP Map store will not have the realm to search for the key at first glance.
Approach
The ID of an entity could be a string containing the realm as a prefix, and the UUID of the entity as a suffix:
REALM#UUIDThe LDAP Map storage will first parse the key to identify the realm. Then it knowns where to look up the UUID.
Benefits
API of map storage can stay the same.
Alternatives
Beta Was this translation helpful? Give feedback.
All reactions