Decorator for SecurityManager in flask appbuilder for superest
Asked Answered
B

1

3

I'm trying to add a custom user information retrieval from OAuth in superset, which is build on top of flask-appbuilder.

Official doc provides following information:

Decorate your method with the SecurityManager oauth_user_info_getter decorator. Make your method accept the exact parameters as on this example, and then return a dictionary with the retrieved user information.

http://flask-appbuilder.readthedocs.io/en/latest/security.html#authentication-oauth

The example in the doc also does not help much, as decorator was put in the comments.

I am where to put custom decorator in Superset? I've put the custom decorator in superset_config.py but I didn't work for me.

Bookmark answered 23/5, 2018 at 15:42 Comment(0)
E
5

The approach that I use boils down to the following:

# For superset version >= 0.25.0

from superset.security import SupersetSecurityManager


class CustomSecurityManager(SupersetSecurityManager):

     def __init__(self, appbuilder):
         super(CustomSecurityManager, self).__init__(appbuilder)

     def whatever_you_want_to_override(self, ...):
         # Your implementation here


CUSTOM_SECURITY_MANAGER = CustomSecurityManager


# For superset version < 0.25.0
from flask_appbuilder.security.sqla.manager import SecurityManager


class CustomSecurityManager(SecurityManager):

     def __init__(self, appbuilder):
         super(CustomSecurityManager, self).__init__(appbuilder)

     def whatever_you_want_to_override(self, ...):
         # Your implementation here


CUSTOM_SECURITY_MANAGER = CustomSecurityManager
Estragon answered 24/5, 2018 at 14:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.