You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/01/20 09:53:01 UTC
[GitHub] [superset] villebro commented on a change in pull request #17757: feat: Authorizing guest access to embedded dashboards
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org