villebro commented on a change in pull request #17757:
URL: https://github.com/apache/superset/pull/17757#discussion_r788576221
##########
File path: superset/security/api.py
##########
@@ -35,7 +35,7 @@ class UserSchema(Schema):
class ResourceSchema(Schema):
- type = fields.String(required=True)
+ type = fields.String(required=True) # todo figure out how to make this an
enum
Review comment:
You can use a
[validator](https://marshmallow.readthedocs.io/en/stable/marshmallow.validate.html)
here:
```python
class ResourceSchema(Schema):
type = Fields.String(
required=True,
validate=validate.OneOf(choices=("option_1", "option_2",
"option_3")),
)
```
##########
File path: superset/security/manager.py
##########
@@ -1097,6 +1103,14 @@ def get_user_by_username(
def get_anonymous_user(self) -> User: # pylint: disable=no-self-use
return AnonymousUserMixin()
+ def get_user_roles(self, user: Optional[User] = None) -> List[Role]:
+ if not user:
+ user = g.user
+ if user.is_anonymous:
+ public_role = current_app.config.get("AUTH_ROLE_PUBLIC")
+ return [self.get_public_role()] if public_role else []
+ return user.roles
Review comment:
I'm surprised this wasn't in the security manager before
--
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]