Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Registry enhancement - Feature to add keycloak roles to the users #3

Conversation

shiva-rakshith
Copy link

@shiva-rakshith shiva-rakshith commented Jun 13, 2022

Usecase scenario:
Creating a user in the registry will create a user in keycloak. currently, we don't have any feature in registry to add keycloak roles to users.

Adding keycloak roles to users, will help to give different privileges to users. For example, we can give access to different users to different APIs based on their roles, which can be extracted from JWT token(as it contains role information).

Sample request body with roles:

{
   "name": "Ravi kumar",
   "roles": ["teacher"],
   "email: "ravi.kumar@gmail.com",
   "phone": "9666505050"
}

The roles property should be of type List, as multiple roles can be assigned to a person.
Whatever the roles is passed in the request body, the same will be added to user in keycloak. If roles property is not define in the request body, registry will consider that as empty list and no role will be added.

Configuration changes:

  1. Define roles in keycloak.
    (keycloak -> roles -> add role)

add-roles (2)

  1. Add the 'view-realm' role to client(admin-api) to access the keycloak roles
    ( Keycloak -> open client(which is configured as client_id in application.yml) -> Service Account Roles -> Client Roles, select 'realm-management' -> Assign 'view-realm' role)

add-view-realm (2)

Future enhancements:

  1. Instead of manually adding the roles in keycloak. Registry should able to add the roles(if not exist) programmatically.

Discussion link: Sunbird-RC/community#178

@shiva-rakshith shiva-rakshith changed the base branch from main to add-keycloak-roles June 16, 2022 09:48
@maheshkumargangula maheshkumargangula merged commit 8fd52bc into Swasth-Digital-Health-Foundation:add-keycloak-roles Jun 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants