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

   <!-- Answer -->
   To resolve the "Access Denied" issue when navigating to `list/users` after 
implementing a custom login setup in Apache Superset, you need to ensure that 
the user has the necessary permissions to access the "List Users" view. The 
"List Users" view is restricted to admin users.
   
   Here is the relevant part of the code that defines the permissions:
   
   ```python
   ADMIN_ONLY_VIEW_MENUS = {
       "Access Requests",
       "Action Log",
       "Log",
       "List Users",
       "List Roles",
       "ResetPasswordView",
       "RoleModelView",
       "Row Level Security",
       "Row Level Security Filters",
       "RowLevelSecurityFiltersModelView",
       "Security",
       "SQL Lab",
       "User Registrations",
       "User's Statistics",
   } | USER_MODEL_VIEWS
   ```
   
   To resolve the issue, you need to ensure that the user has the appropriate 
admin role that includes access to the "List Users" view. You can do this by 
assigning the admin role to the user or by modifying the permissions to include 
the necessary access for the user's role.
   
   Here is an example of how you might assign the admin role to a user:
   
   ```python
   from superset import app, db
   from superset.security.manager import security_manager
   
   # Get the user and role models
   User = security_manager.user_model
   Role = security_manager.role_model
   
   # Fetch the user and admin role
   user = db.session.query(User).filter_by(username='your_username').one()
   admin_role = db.session.query(Role).filter_by(name='Admin').one()
   
   # Assign the admin role to the user
   user.roles.append(admin_role)
   db.session.commit()
   ```
   
   Replace `'your_username'` with the actual username of the user you want to 
grant access to. This will give the user the necessary permissions to access 
the "List Users" view 
<sup>[[1]](https://github.com/apache/superset/blob/master/superset/security/manager.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: [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]

Reply via email to