当前位置:网站首页>About integrating superset into your own project
About integrating superset into your own project
2022-07-31 05:38:00 【Silver fish】
下载&安装
方式一:pip install apache-superset
方式二:https://github.com/apache/superset.git
搭建虚拟环境(可选)
1.安装anaconda (https://www.anaconda.com/products/individual#Downloads)
2.anaconda下run一个python环境,(推荐python3.8)
运行
1.superset db upgrade #初始化数据库
2.superset fab create-admin #初始化用户
3.superset init # 初始化
4.superset run -h 0.0.0.0 -p 8088 --with-threads --reload --debugger # 启动
This process may have many pit,I met a few listed below and the solution:
1.Python-geohash、sasl包有问题:
下载文件安装:https://www.lfd.uci.edu/~gohlke/pythonlibs/#python-geohash
2.markupsafe模块有问题:
安装201版本:pip install markupsafe==2.0.1
3.建议python-v >= 3.8
4.a "wsgi.py" or "app.py" module was not found in the current directory.
CD到app.pyUnder the directory to performsuperset run命令
5.pip install Pillow
未安装Piollow可能会导致run不起来
6.error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio":
下载安装:https://visualstudio.microsoft.com/downloads/
superset的集成
本文用的方式是Button点击跳URLTo the deployment ofsuperset上,The following system and permissions to access account processing.
superset采用flask-appbuilder做身份验证,About how to access the user,The official documentation for details:Security — Flask AppBuilder
本文的思路是:拦截/loginThe request to your own project,Make the function of login and verify.At the same time to the alogin的CallBack URLLet their success in landing back tone system,在回调时把UserWrites the current system ofSession中去.Logout也是同样的道理.都是使用CallBack URL来做的.代码如下:
# config.py
from flask_appbuilder.security.manager import AUTH_REMOTE_USER
from my_security_manager import MySecurityManager
AUTH_TYPE = AUTH_REMOTE_USER # 设置模式
CUSTOM_SECURITY_MANAGER = MySecurityManager # 引入自己写的Security
AUTH_USER_REGISTRATION = True # 允许用户注册
AUTH_USER_REGISTRATION_ROLE = "Gamma" # Set the default add user role
# 与seperset文件夹同级目录下创建 my_security_manager.py
LOGIN_SERVER_URL = 'http://10.113.72.88:5000/login' # Access to the system login interface
CHECK_SERVER_URL = 'http://10.113.72.88:5000/check' # Access to the system oftoken检查接口
LOGINOUT_SERVER_URL = 'http://10.113.72.88:5000/logout' # System access to the appropriate interface
class MyAuthRemoteUserView(AuthRemoteUserView):
# 需继承config.py中AUTH_TYPEThe value corresponding to the parent class
login_template = 'appbuilder/general/security/login_my.html'
title = "My Login"
@expose('/login/', methods=['GET', 'POST'])
def login(self):
token = request.args.get('token')
if not token:
token = request.cookies.get('access_token')
if not token:
return redirect(LOGIN_SERVER_URL)
manager = self.appbuilder.sm
# According to modify your system parameters
result = requests.get(CHECK_SERVER_URL + '?token=' + token)
# According to modify your system validation condition
if result.status_code != 200:
return redirect(LOGIN_SERVER_URL)
# Where access is,只验证token是否有效,All users to entersupersetSee the same page
# 同一个superset账号(admin)
username = "admin"
user = manager.find_user(username=username)
login_user(user, remember=False)
return redirect(self.appbuilder.get_url_for_index)
# Can also according to different login account insupersetGenerated in the different account,Different user interface is different.
# Equivalent to the corresponding access system account number insuperset中进行创建,同时修改login方法,In the custom login.
# if token is not None:
# jwt_payload = jwt.decode(token, 'secret', algorithms=['RS256'])
# 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(AuthRemoteUserView, self).login()
class MySecurityManager(MyAuthRemoteUserView):
authremoteuserview = MyAuthRemoteUserView
边栏推荐
- 11 【定位】
- C语言实验五 循环结构程序设计(二)
- uni-app进阶之创建组件/原生渲染【day9】
- 数据库上机实验6 数据库完整性
- find、filter、map的区别
- leetcode-1833. 雪糕的最大数量(排序+贪心)
- The TOKEN value of Kubernetes joining the cluster expires
- C语言教程(三)-if和循环
- Interviewer: If the order is not paid within 30 minutes, it will be automatically canceled. How to do this?
- C语言文件读、写、定位函数
猜你喜欢
Swordsman Offer Special Assault Edition ---- Day 6
About the problems encountered by Xiaobai installing nodejs (npm WARN config global `--global`, `--local` are deprecated. Use `--location=glob)
uni-app进阶之自定义【day13】
16 【打包上线 图片懒加载】
实验7 UDP与TCP对比
Proteus 8 Professional安装教程
Why use Flink and how to get started with Flink?
剑指offer基础版 ---- 第26天
Volatility取证工具使用日记
【数据库学习】Redis 解析器&&单线程&&模型
随机推荐
Sword Point Offer Special Assault Edition ---- Day 2
11 【组件通信】
Redis管道技术/分区
字符串的新增方法
leetcode-每日一题731. 我的日程安排表 II
13 【代理配置 插槽】
Kubernetes加入集群的TOKEN值过期
数据库上机实验2 单表查询和嵌套查询
uni-app进阶之模版语法与数据绑定【day7】
字符串的扩展
vulhub靶场学习日记xxe-lab
The TOKEN value of Kubernetes joining the cluster expires
Paginate the list collection and display the data on the page
Distributed transaction processing solution big PK!
闭包(二)
闭包(五)----一个常见的循环
Data set partitioning and cross-validation
Flink sink ES 写入 ES(带密码)
实验7 UDP与TCP对比
C语言实验四 循环结构程序设计(一)