Flask appbuilder 中 SecurityManager 的装饰器 for superest

Decorator for SecurityManager in flask appbuilder for superest

我正在尝试在超集中添加从 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