安装管理器的装饰器在烧瓶appbuilder为superest

时间:2018-05-23 15:42:03

标签: python flask apache-superset flask-appbuilder

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

官方文档提供以下信息:

  

使用SecurityManager oauth_user_info_getter装饰您的方法   装饰。让您的方法接受与此相关的确切参数   例如,然后返回一个包含检索到的用户的字典   信息。

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

文档中的

The example也没有多大帮助,因为装饰符放在评论中。

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

1 个答案:

答案 0 :(得分:2)

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

# 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
相关问题