[keycloak-dev] Unable to assign roles from a federation provider

Scott Rossillo srossillo at smartling.com
Mon Jun 15 10:49:05 EDT 2015


Hey all,

I was going to create a JIRA for this, but just want to make sure it’s an actual bug. We are not able to assign roles to a user from a federation provider.

For example, we expected something like this to work from UserFederationProvider. getUserByUsername(RealmModel realm, String username):

        if (remoteUser.getRoles() != null) {
            for (String roleName : remoteUser.getRoles()) {
                RoleModel role = realm.getRole(roleName);
                userModel.getRoleMappings().add(role); // doesn’t work
                userModel.getRealmRoleMappings().add(role); // doesn’t work
            }
        }

However, nothing but the default role is assigned even when we confirm additional roles are assigned to remoteUser and realm.getRole() returns a valid RoleModel.

Create JIRA or should we be assigning roles from a UserFederationProvider in another way?

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/keycloak-dev/attachments/20150615/945cd8d1/attachment.html 


More information about the keycloak-dev mailing list