Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AUTH_ROLES_MAPPING support using Keycloak OAuth #1985

Closed
tp-jssk opened this issue Jan 24, 2023 · 2 comments · Fixed by #2235
Closed

Add AUTH_ROLES_MAPPING support using Keycloak OAuth #1985

tp-jssk opened this issue Jan 24, 2023 · 2 comments · Fixed by #2235

Comments

@tp-jssk
Copy link

tp-jssk commented Jan 24, 2023

AUTH_ROLES_MAPPING is not currently not support using the Keycloak provider.

Mimicking what has been done for Azure, it seems we would need to add a single line of code ("role_keys": me.get("roles", []),) in the return dictionary for the provider Keycloak located here:

@tp-jssk tp-jssk changed the title Added AUTH_ROLES_MAPPING support using Keycloak OAuth Add AUTH_ROLES_MAPPING support using Keycloak OAuth Jan 24, 2023
@fedepad
Copy link
Contributor

fedepad commented Apr 5, 2023

The access token returned by Keycloak can contain client roles and if no action on Keycloak config side is taken (changing the key name from which to retrieve the roles, e.g. to "roles" from the default resource_access.$client_id.roles), usually client roles are available at ["resource_access"]["some_keycloak_client_id"]["roles"], not at "roles" key, so the above won't work.
If this change needs to be done, it should be accompanied by the related Keycloak necessary setup; but might not be possible for everyone to make this change or maybe someone wants to call that key in another name or keep the default.

On the other hand, one can overwrite the method get_oauth_user_info and include roles_keys, whatever they are for the given Keycloak setup and plugin this new FAB security manager class (F.A.B. addon) to retrieve roles either if they are present in "roles" key at the root level or atresource_access.$client_id.roles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
@fedepad @tp-jssk and others