mirror of
https://github.com/bmlong137/alfresco-keycloak.git
synced 2025-09-10 14:11:09 +00:00
Translate input to preferred user name
This commit is contained in:
@@ -313,11 +313,14 @@ public class KeycloakAuthenticationComponent extends AbstractAuthenticationCompo
|
||||
|
||||
final AccessTokenResponse response;
|
||||
final VerifiedTokens tokens;
|
||||
String realUserName = userName;
|
||||
try
|
||||
{
|
||||
response = this.getAccessTokenImpl(userName, new String(password));
|
||||
tokens = AdapterTokenVerifier.verifyTokens(response.getToken(), response.getIdToken(), this.deployment);
|
||||
|
||||
realUserName = tokens.getAccessToken().getPreferredUsername();
|
||||
|
||||
// for potential one-off authentication, we do not care particularly about the token TTL - so no validation here
|
||||
|
||||
if (Boolean.TRUE.equals(this.lastTokenResponseStoreEnabled.get()))
|
||||
@@ -336,7 +339,9 @@ public class KeycloakAuthenticationComponent extends AbstractAuthenticationCompo
|
||||
throw new AuthenticationException("Failed to authenticate against Keycloak", ioex);
|
||||
}
|
||||
|
||||
this.setCurrentUser(userName);
|
||||
// TODO Override setCurrentUser to perform user existence validation and role retrieval for non-Keycloak logins (e.g. via public API
|
||||
// setCurrentUser)
|
||||
this.setCurrentUser(realUserName);
|
||||
this.handleUserTokens(tokens.getAccessToken(), tokens.getIdToken(), true);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user