用于 superest 的 Flask appbuilder 中的 SecurityManager 装饰器

Say*_*ald 3 python flask flask-appbuilder apache-superset

我正在尝试在超集中添加来自 OAuth 的自定义用户信息检索,该超集中构建在 Flask-appbuilder 之上。

官方文档提供以下信息:

使用 SecurityManager oauth_user_info_getter 装饰器装饰您的方法。让您的方法接受本示例中的确切参数,然后返回包含检索到的用户信息的字典。

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

文档中的示例也没有多大帮助,因为装饰器被放在注释中。

我在 Superset 中将自定义装饰器放在哪里?我已将自定义装饰器放在 superset_config.py 中,但我没有为我工作。

dmi*_*igo 5

我使用的方法归结为以下几点:

# 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
Run Code Online (Sandbox Code Playgroud)