dosubot[bot] commented on issue #32023:
URL: https://github.com/apache/superset/issues/32023#issuecomment-2621265468
<!-- Answer -->
To correctly extract roles from the Keycloak response, you need to ensure
that the roles are included in the response from Keycloak. It seems that the
current response does not include any roles. Here are some steps you can take:
1. **Configure Keycloak to Include Roles**: In Keycloak, you need to
configure the client to include roles in the token or userinfo response. This
can typically be done by adding a mapper in the Keycloak client settings. You
can add a "User Realm Role" or "User Client Role" mapper to include roles in
the token.
2. **Update `oauth_user_info` Method**: Once roles are included in the
response, update the `oauth_user_info` method to extract the roles from the
correct field. For example, if roles are included under `realm_access` in the
token, you might access them like this:
```python
roles = data.get('realm_access', {}).get('roles', [])
```
3. **Verify Role Mapping**: Ensure that the roles extracted from Keycloak
match the roles defined in your `AUTH_ROLES_MAPPING` configuration.
By configuring Keycloak to include roles and updating your code to extract
them correctly, you should be able to map Keycloak roles to Superset roles
effectively.
<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
---
<sup>Help Dosu learn! Give it feedback: [Great
Response](https://app.dosu.dev/response-feedback/5b831651-542f-447b-8c38-8153f96b3b95?feedback_type=great_response)
| [Irrelevant
Answer](https://app.dosu.dev/response-feedback/5b831651-542f-447b-8c38-8153f96b3b95?feedback_type=irrelevant_answer)
| [Incorrect
Sources](https://app.dosu.dev/response-feedback/5b831651-542f-447b-8c38-8153f96b3b95?feedback_type=incorrect_sources)
| [Too
Verbose](https://app.dosu.dev/response-feedback/5b831651-542f-447b-8c38-8153f96b3b95?feedback_type=too_verbose)
|
[Hallucination](https://app.dosu.dev/response-feedback/5b831651-542f-447b-8c38-8153f96b3b95?feedback_type=hallucination)
|
[Other](https://app.dosu.dev/response-feedback/5b831651-542f-447b-8c38-8153f96b3b95?feedback_type=other)</sup>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]