All posts
By KateTutorial

Keycloak: adding roles and users

In the Keycloak admin console, open Roles and add the user and admin roles. Then open Users, add a user, set a password on the Credentials tab, and assign a role on the Role Mapping tab.

Keycloak

This blog post is a fourth part of the series. The source code of the complete project is available in this GitHub repository

How do I add roles in Keycloak?

Now we can define Roles, which will be used in our apps for authorization.

In the left menu bar click Roles and then Add Role.

keycloak-roles

Create two roles: user and admin.

Here is the list of the roles of our Demo Realm.

roles-list

How do I add users and assign roles?

Now we can add users. We’ll add two users: one – “standard” user and one – admin user.

In the left menu bar click Users and then Add user.

add-user

For the sake of this tutorial, we’ll add just the minimum of required information, which is just Username:

create-user

Then navigate to the Credentials tab and set the password for the user.

user-password

By default “Temporary” button is ON. That means that the user must change the password on the first login. But we don’t need this feature. So I disabled the Temporary switch.

Now go to Role Mapping tab, where we can assign our user to the role – the user role. For that chose “user” from Available Roles section and press Add selected.

kate-roles

We are done with the first user and now repeat the same actions for creating Admin user.

Add user with username “admin”, set password and role “admin”.

And we’ve finished creating roles and users.

In the next part, we’ll add applications that should be managed by Keycloak.

Next: Keycloak: clients configuration