网站首页 > 博客文章 正文
基于superset的最新version 1.0.0版本实践
aimind_security.py
from superset.security.manager import SupersetSecurityManager
from flask_appbuilder.security.views import *
import logging
log = logging.getLogger(__name__)
class CustomAuthDBView(AuthDBView):
login_template = 'appbuilder/general/security/login_db.html'
@expose('/login/', methods=['GET', 'POST'])
def login(self):
log.info('here1')
token = request.args.get('token')
log.info('here2')
if not token:
token = request.cookies.get('access_token')
if token is not None:
jwt_payload = jwt.decode(token, 'secret', algorithms=['HS256'])
user_name = jwt_payload.get("user_name")
user = self.appbuilder.sm.find_user(username=user_name)
if not user:
role_admin = self.appbuilder.sm.find_role('Admin')
user = self.appbuilder.sm.add_user(user_name, user_name, 'aimind', user_name + "@aimind.com",
role_admin, password="aimind" + user_name)
if user:
login_user(user, remember=False)
redirect_url = request.args.get('redirect')
if not redirect_url:
redirect_url = self.appbuilder.get_url_for_index
return redirect(redirect_url)
else:
return super(CustomAuthDBView, self).login()
else:
flash('Unable to auto login', 'warning')
return super(CustomAuthDBView, self).login()
class CustomSecurityManager(SupersetSecurityManager):
authdbview = CustomAuthDBView
然后再config.py中增加两部分引用,中间行为引入部分
from superset.utils.logging_configurator import DefaultLoggingConfigurator
from .aimind_security import CustomSecurityManager
logger = logging.getLogger(__name__)
非注释部分为引入内容
# ----------------------------------------------------
# AUTHENTICATION CONFIG
# ----------------------------------------------------
# The authentication type
# AUTH_OID : Is for OpenID
# AUTH_DB : Is for database (username/password)
# AUTH_LDAP : Is for LDAP
# AUTH_REMOTE_USER : Is for using REMOTE_USER from web server
AUTH_TYPE = AUTH_DB
CUSTOM_SECURITY_MANAGER = CustomSecurityManager
# Uncomment to setup Full admin role name
# AUTH_ROLE_ADMIN = 'Admin'
关于最新版本汉化问题 注释掉最后的一行
# ---------------------------------------------------
# Babel config for translations
# ---------------------------------------------------
# Setup default language
BABEL_DEFAULT_LOCALE = "zh"
# Your application default translation path
BABEL_DEFAULT_FOLDER = "superset/translations"
# The allowed translation for you app
LANGUAGES = {
"en": {"flag": "us", "name": "English"},
"es": {"flag": "es", "name": "Spanish"},
"it": {"flag": "it", "name": "Italian"},
"fr": {"flag": "fr", "name": "French"},
"zh": {"flag": "cn", "name": "Chinese"},
"ja": {"flag": "jp", "name": "Japanese"},
"de": {"flag": "de", "name": "German"},
"pt": {"flag": "pt", "name": "Portuguese"},
"pt_BR": {"flag": "br", "name": "Brazilian Portuguese"},
"ru": {"flag": "ru", "name": "Russian"},
"ko": {"flag": "kr", "name": "Korean"},
}
# Turning off i18n by default as translation in most languages are
# incomplete and not well maintained.
#LANGUAGES = {}
隐藏图标的方式 将width设置成0
# Uncomment to setup an App icon
APP_ICON = "/static/assets/images/superset-logo-horiz.png"
APP_ICON_WIDTH = 0
跨域访问部分的配置
# CORS Options
ENABLE_CORS = True
#CORS_OPTIONS: Dict[Any, Any] = {}
CORS_OPTIONS: Dict[Any, Any] = {"origins": "*"}
# Chrome allows up to 6 open connections per domain at a time. When there are more
# than 6 slices in dashboard, a lot of time fetch requests are queued up and wait for
# next available socket. PR #5039 is trying to allow domain sharding for Superset,
# and this feature will be enabled by configuration only (by default Superset
# doesn't allow cross-domain request).
SUPERSET_WEBSERVER_DOMAINS = []
效果如下
转载于https://www.cnblogs.com/xiaoqi/p/intergate-superset.html
猜你喜欢
- 2024-09-10 深圳社会志愿者服务管理平台的设计与实现技术方案
- 2024-09-10 web鉴权access_token、AK/SK、session/cookie
- 2024-09-10 如何用Python和Google“自动化”我的婚礼?
- 2024-09-10 Celery与Django:打造高效DevOps的定时任务与异步处理神器
- 2024-09-10 Python面试者必看!245道经典Python面试题及答案解析,可下载
- 2024-09-10 Python如何实现用户鉴权(python用户认证)
- 2024-09-10 traefik hub配置与使用(traefik 设置客户端ip)
- 2024-09-10 Python 潮流周刊#67:uv 的重磅更新(摘要)
- 2024-09-10 聊一聊我认识的Python安全(python的安全性)
- 2024-09-10 cookie、session、token区别(cookiesessiontoken区别)
你 发表评论:
欢迎- 06-23MySQL合集-mysql5.7及mysql8的一些特性
- 06-23MySQL CREATE TABLE 简单设计模板交流
- 06-23MYSQL表设计规范(mysql设计表注意事项)
- 06-23MySQL数据库入门(四)数据类型简介
- 06-23数据丢失?别慌!MySQL备份恢复攻略
- 06-23MySQL设计规范(mysql 设计)
- 06-23MySQL数据实时增量同步到Elasticsearch
- 06-23MySQL 避坑指南之隐式数据类型转换
- 最近发表
- 标签列表
-
- powershellfor (55)
- messagesource (56)
- aspose.pdf破解版 (56)
- promise.race (63)
- 2019cad序列号和密钥激活码 (62)
- window.performance (66)
- qt删除文件夹 (72)
- mysqlcaching_sha2_password (64)
- ubuntu升级gcc (58)
- nacos启动失败 (64)
- ssh-add (70)
- jwt漏洞 (58)
- macos14下载 (58)
- yarnnode (62)
- abstractqueuedsynchronizer (64)
- source~/.bashrc没有那个文件或目录 (65)
- springboot整合activiti工作流 (70)
- jmeter插件下载 (61)
- 抓包分析 (60)
- idea创建mavenweb项目 (65)
- vue回到顶部 (57)
- qcombobox样式表 (68)
- vue数组concat (56)
- tomcatundertow (58)
- pastemac (61)
本文暂时没有评论,来添加一个吧(●'◡'●)