Is it possible to configure user in realm with rights to read/modify roles and users - keycloak

Is it possible to configure in keycloak realm (but not in a master realm) to give users access to admin api.
I want to be able as a keycloak user to configure other user roles/scopes etc.
It will be done from fronted service so it cannot be done using service account.

Is it possible to configure in keycloak realm (but not in a master
realm) to give users access to admin api.
Yes, for that you need to:
(Old Keycloak UI)
Go to the target Realm;
Go to users and click on the user to add the roles;
Switch to the tab Role Mappings
On the Client Roles dropdown menu select realm-management
and assign the roles accordingly.
(New Keycloak UI)
Go to the target Realm;
Go to users and click on the user to add the roles;
Click on Assign role
In Search by role name type the desired role
Select the role and assign it

Related

BPM Process for User Group (keycloak)

I've just integrated keycloak with jBPM. Now I can login to jBPM console with keycloak user's credentials and get related roles.
I created some User Groups in keyClock console and mapped some users along with those
User Groups in keyClock console. But I don't have any User Groups in jBPM that I mapped to my user in Keycloak console.
I have created (BPM) process with human task assigned to User Group (entered name of User Group created in Keycloak). This task was unavailable for the user that had this User Group in keycloak mapping.
How to map users to a group using keyCloak that reflects in jBPM?
Actually a role in Keycloak is a group in jBPM.
Create roles in keyCloak (desired user groups in jBPM) and assign those roles to users.
Now processes for specified User Groups (in jBPM) will be visible to users with corresponding roles in keyCloak server.
Note : You may need to create a default role user in keyCloak server that will be mapped to default jBPM user role.

How to define more fine-grained permissions or custom logic for built-in roles in Keycloak

Keycloak provides some built-in roles to manage keycloak itself. These roles are defined in the realm-management client of every non-master realm. As example, I can define a user which has the permissions to manage users. But now this user can change all the roles of all the users. The user can even change the role of itself.
In our application we need a hierarchical role structure in the following way. We have a root, admin and some other specific application roles. The root role should be able to manage the keycloak customer realm as also some application specific functionality. The admin role should have the permissions to manage users and also some application specific functionality.
I have tried to model that in keycloak the following way. I have two realm roles root and admin as also some client (my-app) roles root, admin, edit and view. The realm roles are composite roles which use their counterpart in the client (root -> may-app.root, admin -> my-app.admin).
Now, the issues is that the admin user can change it's role to root. How can I restrict the permissions of the admin user to allow only to manage user or roles that are on the same level or below? Is their such built-in functionality or should I provide my own UI on top of the Keycloak REST API?

Exclude a user with realm-management role from keycloak's password policy

I have a user with Client Roles realm-management in a realm which contains password policy.
I want to exclude this user from the password policy since I use this user to do some operation fetch the roles get all the user via Java API and I don't want all the operation to be drop when the password needs to be updated.
I tried to use the admin user from the master realms but I did not get any result
Any ideas?
When you create a realm in keycloak with password policy and you want to exclude the admin user from this policy do this follow these steps :
When a user creates new realm e.g "FooRealm" keycloak adds sibling client inside the master realm with a suffix -realm, in this case, we will see FooRealm-realm
Inside this client, FooRealm-realm do those changes (settings tab)
access type = confidential
Standard Flow Enables = ON
Direct Access Grants Enables = ON
Create user inside the master realm, In user details, go to: Role Mappings >> Clients Roles and from the drop down menu select the sibling client
(FooRealm-realm) and make sure it is own all the roles inside
Now To fetch all the user from the Slave realm FooRealm
Keycloak keycloak = KeycloakBuilder.builder()
.serverUrl("http://localhost/auth")
.realm("master")
.grantType(OAuth2Constants.PASSWORD)
.clientId(FooRealm-realm)
.clientSecret("7f0080cf-xxxx-xxxxx-9115-xxxxxxxxxx")
.username("sysadmin")
.password("x123456")
.build();
RealmResource realmResource = keycloak.realm("FooRealm");
realmResource.users().list(0, 1000);

Disable impersonation of a group, or for a realm within KeyCloak?

KeyCloak question for everyone.
Is it possible to disable impersonation of a group (for example, an admin group), or for a realm (the admin management console)?
Thx
You can assign impersonation role for a user from Client Roles of the realm.
Each realm has a built-in client called realm-management. This client defines client-level roles that specify permissions that can be granted to manage the realm.
You can find more on available roles from Keycloak docs
Once you remove impersonation client-level role for your realm , it is not available for all users of the realm.

Keycloak - Users in Role missing after sync with LDAP

I configured LDAP as User Federation (with role-ldap-mapper) and successfully imported users with their roles to Keycloak.
When I go to Users->{user}->Role Mappings I see every roles that are signed to a user (imported from LDAP), but when I go to Roles->{role}->Users In Role I see nothing.
Is it a bug or a feature? Or maybe I configure something wrong?
Users roles
Empty Users in Roles
LDPA Role mapper configuration
I faced the same issue. I changed the Mode (inside LDAP role mapper) to Import instead of READ_ONLY and I was able to see users under a role.
Please create mapper of type msad-lds-user-account-control-mapper.
It works for me.