Check whether CREATE_REALM role exists in realm role mappings before hasRole check for user.

Closes #20332
This commit is contained in:
Sazzad Hossain 2023-05-30 19:42:48 +06:00 committed by Marek Posolda
parent f526f7a091
commit 41e253c054

View file

@ -227,7 +227,10 @@ public class AdminConsole {
boolean createRealm = false;
if (realm.equals(masterRealm)) {
logger.debug("setting up realm access for a master realm user");
createRealm = user.hasRole(masterRealm.getRole(AdminRoles.CREATE_REALM));
RoleModel createRealmRole = masterRealm.getRole(AdminRoles.CREATE_REALM);
if (createRealmRole != null) {
createRealm = user.hasRole(createRealmRole);
}
addMasterRealmAccess(user, realmAccess);
} else {
logger.debug("setting up realm access for a realm user");