问题
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.
回答1:
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
来源:https://stackoverflow.com/questions/50492494/decorator-for-securitymanager-in-flask-appbuilder-for-superest