我正在尝试在超集中添加从 OAuth 检索的自定义用户信息,该超集中构建在 Flask-appbuilder 之上。
官方文档提供以下信息:
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在文档中也没有多大帮助,因为装饰器被放在注释中。
我在 Superset 中将自定义装饰器放在哪里?我已将自定义装饰器放在 superset_config.py 中,但我没有为我工作。
最佳答案
我使用的方法归结为以下几点:
# 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
关于python - 用于 superest 的 Flask appbuilder 中的 SecurityManager 装饰器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50492494/