keycloak/keycloak-nodejs-admin-client

Unable to specify roles with new user creation

ehogeweg opened this issue · 1 comments

Describe the bug

I am not sure if this is a bug or just a user error, but I can't figure it out.

When I create a new user all the fields in keyCloak are correct, except the role(s) are missing on the User.

  const user = {
        firstName: existingUser.first_name,
        lastName: existingUser.last_name,
        realmRoles: ["admin"],
        groups: ["aGroup"],
<snip>

Everything appears to be correct in the body of the message.

{"credentials":[{"algorithm":"bcrypt","hashedSaltedValue":"$2a$10$.deleted.","hashIterations":10,"type":"password"}],"email":"aap@gmail.com","username":"aap.noot","emailVerified":true,"enabled":true,"firstName":"Aap","lastName":"Noot","realmRoles":["admin"],"groups":["aGroup"]}

Any help is greatly appreciated.

Cheers,

Dutch

Version

19.0.3

Expected behavior

I expect, maybe incorrectly, that the specified role(s) show up under the User in keyCloak.

Actual behavior

Specified role(s) are missing.

How to Reproduce?

  const user = {
    realm: AUTH_REALM_NAME,
    ...
    username: existingUser.login,
    ...
    realmRoles: ["admin"],
    groups: ["aGroup"],
  };
  await kcAdminClient.users.create(user);

Anything else?

No response

Looks like this is a dupe of 253. Not sure that one should have been closed though...