How to assign specific role to a user for a group in keycloak - keycloak

I created a group in keycloak and i added users to the group. I want to add one user as the group admin of the group by adding ADMIN role to one user and other users should remain with USER role.
One user can belongs to multiple groups. As an example User_A can be in Group_A, Group_B and Group_C. And also User_A is the admin of Group_A and in Group_B and Group_C, he is a normal user.
Is there any way to achieve this requirement in keycloak?
Please let me know is there any solution.

You could have a sub-group admin with default ADMIN role below Group_A , and put User A in that sub-group.
Or why don't you just assign individual ADMIN role to User_A ?
As I understand groups function in keycloak, it is essentially a way of assigning automatic attributes/roles to user (and...to group them). But roles assigned via groups function are exactly the same as individual roles I think.

Related

Best practices for creating a admin role group in PostgreSQL

I'm currently trying to find the best process for managing admin privileges throughout my PostgreSQL databases. What I am trying to do is assign permissions that are sufficient enough for in an admin role group where I can GRANT a user (another admin) to inherit the permissions of the role group; however, I'm not sure if this can be done or how to do this. The admin role group's privileges should be the following:
Able to add users
Able to view users and permissions in a database
Able to reset a user's password, dropping a user, or resetting a user's name
Able to show grants of a particular user
Able to add specific permissions for a user to a schema and table. (So have permissions to the database and tables)
For auditing purposes, should I even go with this approach of creating a role group or add a user (admin) with no role group? I remember reading that the role group would show as who did any changes rather than the specific user. Would appreciate clarification on this.
Thanks for reading my post.

How can I get ldap-sync for postgres to grant the AD Group role to its group-members?

We are using ldap-sync (github.com/larskanis/pg-ldap-sync) to bring members of an AD Group into a postgres cluster as user-roles however the user role that is based on the AD Group is not being granted to the user role based on the AD Account that is a member of that group. How can we achieve this?

Keycloak impersonation only for certain users

I am currently trying to set up keycloak for a production scenario in which I have different contexts, each with users and admins. The admin should only be able to impersonate users from his context.
Giving an admin permission in the form of permissions to impersonate all users is not a problem. but how can I solve the above task? Can one of keycloak built in concepts (groups, roles, realms, scopes etc.) help me?
You have to enable --features=admin-fine-grained-authz and then.
Put your users into a group.
Create another user and grant this user "query-groups" and
"impersonation" roles (from the "realm-management" or "master-realm"
client, depending on the realm).
Go to your group, enable permissions, open "view" permission, and add a
user policy to allow the user to view a group, then repeat for "view-members" permission.
FInd more details here
and here

How to allow an employee to login to system only if role has been assigned by admin in yii2?

I am using yii2 basic and have implemented RBAC using permissions, roles.
I have Employee table and I have assigned Employee model to user application component.
Now the scenario is when admin creates employee he has to assign a role to that employee using auth_assignment CRUD.
Unless and until role has been assigned, the employee should not be able to login. Login page should be displayed to him with error message. (Similar to the scenario when incorrect username or password is entered by user.)
How to accomplish this?

What role is being checked by #RolesAllowed() in keycloak

I am using keycloak, and I have created a dropwizard service that I want to start enforcing roles in.
I have tried using the #RolesAllowd("user") annotation, but it always returns 403.
I have also tried #PermitAll, and that works fine.
I know I am connected correctly to the server, as the user has the correct information in it (email, name, etc), but where do the roles come from?
Is there a way to see the roles that a user has?
(answering my own question)
The issue that I was having #RolesAllowd("user") always returns a 403, is because of a checkbox in the Keycloak UI called "Scope Param Required". and the tooltip reads:
This role will be granted just if scope parameter with role name is used during authorization/token request.
It turns out, if you are trying to use that role, and the checkbox is on, it will not be sent to the client, so it will seem to the client that the user does not have that role. That checkbox was clicked ON for me, so that is why the annotation was showing the user was not authenticated.
So, if that checkbox is checked, you need to explicitly ask for the role, here is how you do that with user:
"scope" : {
"realm" : [ "user" ]
}
And here is more information from Keyclaok: https://issues.jboss.org/browse/KEYCLOAK-231
In your application realm on the keycloak admin console, you have a section called roles. There you must add the roles that will be checked by java security.
If you want that a user after a registration automatically receive a role, you need to add this role into default roles (roles -> default roles). You can also add manually roles to existent users in users -(select a user)->role mapping->assigned roles