dosubot[bot] commented on issue #29523:
URL: https://github.com/apache/superset/issues/29523#issuecomment-2217293472

   <!-- Answer -->
   To ensure that the role field is mandatory for users logging in via OAuth in 
Superset without modifying the codebase, you can configure the 
`AUTH_USER_REGISTRATION_ROLE` and `AUTH_ROLES_MAPPING` in your 
`superset_config.py` file. This will ensure that users are assigned a default 
role upon registration and map OAuth groups to Superset roles.
   
   Here is how you can configure it:
   
   1. Set the default user registration role:
       ```python
       AUTH_USER_REGISTRATION_ROLE = "Public"  # or any other default role you 
prefer
       ```
   
   2. Map OAuth groups to Superset roles to ensure users are assigned roles 
based on their OAuth group:
       ```python
       AUTH_ROLES_MAPPING = {
           "oauth_group_name": ["SupersetRole1", "SupersetRole2"],
           "another_oauth_group": ["AnotherSupersetRole"]
       }
       ```
   
   3. Ensure roles are synced at login:
       ```python
       AUTH_ROLES_SYNC_AT_LOGIN = True
       ```
   
   By setting these configurations, you ensure that every user logging in via 
OAuth is assigned a role, making the role field effectively mandatory.
   
   Here is the complete configuration snippet for `superset_config.py`:
   
   ```python
   # Default user self registration role
   AUTH_USER_REGISTRATION_ROLE = "Public"
   
   # Mapping OAUTH groups to Superset roles
   AUTH_ROLES_MAPPING = {
       "oauth_group_name": ["SupersetRole1", "SupersetRole2"],
       "another_oauth_group": ["AnotherSupersetRole"]
   }
   
   # Sync roles at login
   AUTH_ROLES_SYNC_AT_LOGIN = True
   ```
   
   This configuration ensures that users logging in via OAuth are assigned 
roles based on their OAuth group, making the role field mandatory without 
modifying the codebase 
<sup>[[1]](https://github.com/apache/superset/blob/master/docs/docs/configuration/configuring-superset.mdx)</sup><sup>[[2]](https://github.com/apache/superset/blob/master/superset/config.py)</sup>.
   
   
   <!-- Dosu Comment Footer -->
   *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
   


-- 
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: notifications-unsubscr...@superset.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org
For additional commands, e-mail: notifications-h...@superset.apache.org

Reply via email to