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

标签 python flask apache-superset flask-appbuilder

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

相关文章:

python时间+ timedelta等效

python - 如何简化 numpy 条件语句来查找给定值的元素的相邻索引?

javascript - 超集 map 框工具提示的个性化

docker-compose - 如何更改生产非开发的超集配置 config.py

python - 从 Ruby 客户端访问 Python XML-RPC 服务

python - 来自 Django-Pandas 查询集的 Pandas 数据透视表

python - 在 Flask/WTForms 中创建具有不同数量重复子表单的表单

python - Flask 设置代码运行一次,但不在测试期间运行

python - 需要一个类似字节的对象而不是 'str'