[keycloak-user] getRoleMappings - please I need a help
Juan Pablo Perata
jpperata at gmail.com
Sat Feb 10 13:36:35 EST 2018
+1 to the question.
I faced the same problem and got stuck with getRoleMappingsInternal().
I tried debugging keycloak code where this method is called and legacy
system roles were retrieved but not added to the final list of role
mappings. I had not enough time to dig more into the problem but seems that
if role is not defined in keycloak realm, then role is not added.
What I ended up doing was thinking another approach: creating a servlet in
application which is called after authentication succeeds.
Another option would be to have a filter. It depends on your needs.
Hope it helps. It would be great if you can share your experience too or if
you found the way.
Regards,
Juan
On Mon, Jan 29, 2018 at 4:47 PM, JOSE INACIO DA SILVA JUNIOR <
inacio-silva at prodesan.com.br> wrote:
> Hi,
>
> I'm changing PropertyFileUserStorageProvider example. And I need to
> override the method: Set<RoleModel> getRoleMappingsInternal(); of the class
>
> AbstractUserAdapterFederatedStorage.class in order to retrive external
> roles based on a legacy system.
>
> How can I do that?
>
> I've tried:
>
> protected Set<RoleModel> getRoleMappingsInternal() {
>
> Set<RoleModel> roles = new HashSet<>();
> RoleModel role = new MyRoleAdapter(realm,"role1","role1","role1
> description", false);
> roles.add(role);
> return roles;
>
> }
>
> The code of MyRoleAdapter:
>
>
> public class MyRoleAdapter implements RoleModel{
> private String id;
> private String name;
> private String description;
> private RealmModel container;
> private boolean isClientRole;
>
> public RoleProdesanAdapter(RealmModel container, String id, String
> name, String description, boolean isClientRole) {
> this.id = id;
> this.name = name;
> this.description = description;
> this.container = container;
> this.isClientRole = isClientRole;
> }
>
> // getters
> }
>
>
> Please help me. I've tried a lot but without success!
>
>
> Thanks in advance!
> Inácio
>
>
>
>
> _______________________________________________
> keycloak-user mailing list
> keycloak-user at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/keycloak-user
More information about the keycloak-user
mailing list