question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The realm role is not added when creating a user.

See original GitHub issue

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior: When creating a user, I call the kcAdminClient.users.create function.

I pass the object there:

{
      realm: 'SOME_REALM',
      username: userData.username,
      email: userData.email,
      firstName: userData.firstName,
      lastName: userData.lastName,
      enabled: true,
      requiredActions: [
        RequiredActionAlias.VERIFY_EMAIL,
      ],
      realmRoles: ['CLIENT_ADMIN'],
}

But after the user is created, the role is not applied to the user.

Expected behavior The roles that are transferred in the array are applied to the user.

Enviroment (please complete the following information):

  • OS: [Ubuntu]
  • Keycloak Version: 15.0.0
  • Library Version: 15.0.2

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
amoscatellicommented, Nov 9, 2022

@lmorningstar116

Why has this issue being closed ?

There is a sort of workaround, but the issue is still present (and api seems broken).

What if I don’t want to assign a group ?

0reactions
lmorningstar116commented, Oct 4, 2021

By the way, you could equally just add groups: [<some-groups>] to the user payload and it will do something as above. Assuming the groups have been assigned necessary roles you want users to have.

Yes, the group solution did the trick. At first it will work, but this behavior is very strange.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Realm role is not assigned while creating user - Getting advice
Currently user is created and credentials are assigned, but role is not assigned. I created this role manually using administrator console.
Read more >
Unable to assign realm Role to a newly created Keycloak ...
Problem: The user is successfully created but it is not assigned a role (realmRole). After some more research I found that this behaviour...
Read more >
Mapper "User Realm Role" does not include group ... - Red Hat
Mapper "User Realm Role" adds the current user's realm roles to the ID token and/or access token. However, it seems that it's only...
Read more >
Using Keycloak Admin Client to create user with roles (Realm ...
Create a realm, Go to your realm in Keycloak, go to the users, create a user, just give it username, then save, go...
Read more >
Mapping users and groups to roles | Elasticsearch Guide [8.5]
When you use role mappings to assign roles to users, the roles must exist. There are two sources of roles. The available roles...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found