Repository navigation
Replies: 9 comments 16 replies
No, in the new storage it should be possible to keep letter case. The current behaviour does not cover some usecases and we already had RFEs for keeping the letter case as provided:
These RFEs were rejected by the time of their triage since the decision was based on legacy implementation of the storage. The new store may behave differently. I believe the user storage map provider should specify an option whether username letter case is significant or not. If not, let's search by lowercase / uppercase (could be an option of the provider). The storage implementation might lack the feature support for either of these - for example for external sources (say LDAP or REST) it cannot arbitrarily set whether they do or do not support letter case resolution. Keycloak has to follow their settings. |
|
I agree that the store in the future should keep the lettercase, then we rather solve it when looking up user based on username. I can see folks wanting both to solve the problem with LDAP/saml/etc and also still perhaps wanting to just type username with lowercase perhaps. Any ways okay with the change in general as long as current (oddities) don't end up being blockers or breaking behaviour. |
|
On the last team call we've discussed that the best solution, to allow storing username in case-sensitive format and also to be able to support fast search when searching in case-insensitive mode, would be to store both variants of the username (both This decision implies that we might enhance the Then the There would be some stores, added in a future, which won't allow to distinguish letter case. Those stores should throw the Tree store then should manage the setting for the whole tree and ensure it is set correctly. |
|
@vramik Question regarding the usernameSensitivity switch. Should we take it into account only in the method Example: given we have storage configured as case sensitive, and we have the following users /cc @hmlnarik [1] https://github.com/keycloak/keycloak/blob/main/model/map/src/main/java/org/keycloak/models/map/user/MapUserProvider.java#L609 |
|
Heterogeneous cluster Homogeneous cluster Also it's expected that administrator is responsible there are no-collinding usernames upon change of the setting from |
|
Sorry if this is not the place to ask, but Is there any new version where you can save usernames with upper case characters? |
|
Hello ! Is theire now a simple way to retrieve/enable username case sensitive login/retrieve ? I dont see anything about this in the documentation. All issues mention user cache disable, but has i see in this conversation, do you have implement this feature ? |
|
Hi are there any upadte on this feature? |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
looking at the code it seems we always store user's username (and also email) in lowered-case format: https://github.com/keycloak/keycloak/blob/main/model/jpa/src/main/java/org/keycloak/models/jpa/JpaUserProvider.java#L110 and https://github.com/keycloak/keycloak/blob/main/model/map/src/main/java/org/keycloak/models/map/user/MapUserProvider.java#L337 even though it's not specified in java-doc.
Then when looking up for a user by the given username it's specified by java-doc that the username should be:
@param username case insensitive username (case-sensitivity is controlled by storage)JpaUserProvideruses named querygetRealmUserByUsername:select u from UserEntity u where u.username = :username and u.realmId = :realmIdand param username is set byquery.setParameter("username", username.toLowerCase())... this query is supported by indexMapUserProvideruses MCB where operatorILIKEis used: https://github.com/keycloak/keycloak/blob/main/model/map/src/main/java/org/keycloak/models/map/user/MapUserProvider.java#L511 ... if it'd be implemented usingILIKEoperator the index couldn't be used.Question: Could it be safely assumed that username is always stored in lowered-case format? Or is that implementation specific?
Based on that we should decide if we could:
MapUserProviderto use operatorEQ:.compare(SearchableFields.USERNAME, Operator.EQ, username.toLowerCase());UserProvider.addUserspecifying that username should be stored as lower-caseUserLookupProvider.getUserByUsernamesaying it is exact case-insensitive searchnote: it probably applies to email as well, but
MapStorageProvider.getUserByEmailis implemented following way:.compare(SearchableFields.EMAIL, Operator.EQ, email);- there is noemail.toLowerCase(), whileJpaUserProviderusesemail.toLowerCase().EDIT: Related issues:
All reactions