Skip to content

Commit

Permalink
Update services/src/main/java/org/keycloak/events/log/JBossLoggingEve…
Browse files Browse the repository at this point in the history
…ntListenerProvider.java

Co-authored-by: Václav Muzikář <[email protected]>
Signed-off-by: Peter Zaoral <[email protected]>
  • Loading branch information
Pepo48 and vmuzikar authored Aug 19, 2024
1 parent 40889f1 commit 5b815c1
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,16 @@ private void logEvent(Event event) {
logger.log(logger.isTraceEnabled() ? Logger.Level.TRACE : level, sb.toString());
}

RealmModel realm = session.realms().getRealm(event.getRealmId());
UserModel user = session.users().getUserById(realm, event.getUserId());
ClientModel client = session.clients().getClientByClientId(realm, event.getClientId());

if (EventType.LOGIN.equals(event.getType()) && Boolean.parseBoolean(user.getFirstAttribute(TEMP_ADMIN_ATTR_NAME))) {
logger.warn(user.getUsername() + " is a temporary admin user account. To harden security, create a permanent account and delete the temporary one.");
}

if (EventType.CLIENT_LOGIN.equals(event.getType()) && Boolean.parseBoolean(client.getAttribute(TEMP_ADMIN_ATTR_NAME))) {
logger.warn(client.getClientId() + " is a temporary admin service account. To harden security, create a permanent account and delete the temporary one.");
if (event.getRealmName().equals(Config.getAdminRealm()) && (EventType.LOGIN.equals(event.getType()) || EventType.CLIENT_LOGIN.equals(event.getType()))) {
RealmModel realm = session.realms().getRealm(event.getRealmId());
UserModel user = session.users().getUserById(realm, event.getUserId());
ClientModel client = session.clients().getClientByClientId(realm, event.getClientId());

if (EventType.LOGIN.equals(event.getType()) && Boolean.parseBoolean(user.getFirstAttribute(TEMP_ADMIN_ATTR_NAME))) {
logger.warn(user.getUsername() + " is a temporary admin user account. To harden security, create a permanent account and delete the temporary one.");
} else if (EventType.CLIENT_LOGIN.equals(event.getType()) && Boolean.parseBoolean(client.getAttribute(TEMP_ADMIN_ATTR_NAME))) {
logger.warn(client.getClientId() + " is a temporary admin service account. To harden security, create a permanent account and delete the temporary one.");
}
}
}

Expand Down

0 comments on commit 5b815c1

Please sign in to comment.