Superset集成LDAP经验总结 | KavenRan's Blog
source link: https://ranying666.github.io/2019/06/06/superset-ldap/?
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
KavenRan
写个机器人来取代自己
团队需要解决Superset的单点登录问题,看网上有集成LDAP的经验,根据配置但并未成功,经过摸索和阅读源码,终于搞定了,分享一下。
- version: 0.28.1
- 安装方式:docker
修改配置文件:/usr/local/lib/python3.6/site-packages/superset/config.py
1 | # 引入AUTH_LDAP |
如果你配置了AUTH_LDAP_APPEND_DOMAIN 或 AUTH_LDAP_USERNAME_FORMAT,那要保证接起来的DN是可登录的。
AUTH_LDAP_UID_FIELD 默认是uid,而我们LDAP是用cn作为用户名,所以也必须配置。
- AUTH_USER_REGISTRATION:允许验证用户注册,之前这个没有打开,一直提示用户密码不正确,跟踪源码发现,LDAP用户验证通过后会自动注册用户成为superset自己的用户,如果没有打开就会返回None,当然登录不了。
1
2
3
4
5
6
7
8def auth_user_ldap(self, username, password):
.....
# If user does not exist on the DB and not self user registration, go away
if not user and not self.auth_user_registration:
return None
......
Flask-AppBuilder源代码:
https://github.com/dpgaspar/Flask-AppBuilder/blob/master/flask_appbuilder/security/manager.py
- AUTH_USER_REGISTRATION_ROLE:默认Public角色,权限太少,修改为admin角色。
参数含义说明:
https://github.com/dpgaspar/Flask-AppBuilder/blob/master/docs/config.rst
如果你想从源代码重新打镜像,下载代码修改:https://github.com/apache/incubator-superset/blob/master/contrib/docker/superset_config.py
基于0.28.1叠加一层打包:Dockerfile
1 | FROM 10.1.1.2/bigdata/superset:0.28.1 |
build镜像:docker build -t 10.1.1.2/bigdata/superset:0.28.2 .
挂载启动:
1 | docker run -ti -p 8088:8088 -v /opt/app/dockerimages/superset:/home/superset 10.1.1.2/bigdata/superset:0.28.2 /bin/bash |
1 | $ /usr/local/bin/superset-init --username admin --firstname admin --lastname user --email [email protected] --password admin |
启动web server:
1 | superset runserver |
debug模式启动:
1 | superset runserver -d --console-log |
官方镜像默认没有console-log,需要自己安装:
cd /usr/local/lib/python3.6/site-packages/
pip install console-log
- 打出详细的日志是解决问题要做的第一件事
- 源码永远是最好的文档
- 如果问题一直解决不了,你应该回顾一下你选择这条路是不是对的,找一切证据证明你是对的,能证明就坚定的走下来,如果不能证明,你应该考虑及时换一条路
LDAP服务器的概念和原理简单介绍:
https://segmentfault.com/a/1190000002607140
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK