Do not try to lookup the user if the sub claim is missing from the admin bearer token (#41981)

Closes #41098

Signed-off-by: Pedro Igor <pigor.craveiro@gmail.com>
This commit is contained in:
Pedro Igor
2025-08-19 11:45:44 -03:00
committed by GitHub
parent d7e6ccb267
commit 08de42a57d

View File

@@ -297,9 +297,10 @@ public abstract class DefaultKeycloakContext implements KeycloakContext {
String issuer = jwt.getIssuer();
String realmName = issuer.substring(issuer.lastIndexOf("/") + 1);
RealmModel realm = session.realms().getRealmByName(realmName);
String id = jwt.getSubject();
if (realm != null) {
user = session.users().getUserById(realm, jwt.getSubject());
if (realm != null && id != null) {
user = session.users().getUserById(realm, id);
}
}