最近,我综合超集与我的网应用程序,以便在一个用户身份验证通过我的网应用可以输入超集和查/编辑/仪表板创建基于自己的作用只是通过点击的链接,不需要甚至登录。 这样做我不得不绕过登录为此,我提 这 篇文章。
定义SecurityManager我用来绕过登录
class CustomAuthDBView(AuthDBView):
@expose('/login/', methods=['GET', 'POST'])
def login(self):
redirect_url = self.appbuilder.get_url_for_index
user_name = request.args.get('username')
user_role = request.args.get('role')
if user_name is not None:
user = self.appbuilder.sm.find_user(username=user_name)
if not user:
role = self.appbuilder.sm.find_role(user_role)
user = self.appbuilder.sm.add_user(user_name, user_name, 'last_name', user_name + "@domain.com", role, password = "password")
if user:
login_user(user, remember=False)
return redirect(redirect_url)
else:
print('Unable to auto login', 'warning')
return super(CustomAuthDBView,self).login()
class CustomSecurityManager(SupersetSecurityManager):
authdbview = CustomAuthDBView
def __init__(self, appbuilder):
super(CustomSecurityManager, self).__init__(appbuilder)
因此,根据上述代码使用url http://localhost:8088/login?username=John
将登录用户的约翰内,或者如果用户约翰不存帐户创造了一些作用,这是基于角色的用户在我的网络应用程序
现在问题是谁能猜到这个网址 http://localhost:8088/login?username=USER_NAME
可创建自己的帐户中超集,那么如何保护或安全这个 '/login'
终结点