How to enable normal sign in and SSO at same time. #32991
Replies: 3 comments
-
|
To enable both normal sign-in and SSO simultaneously in Apache Superset, allowing users to log in with either SSO or a username and password, you can implement a custom authentication flow using a custom security manager. Here's how you can achieve this:
from flask import redirect, flash, request
from superset.security import SupersetSecurityManager
from flask_login import login_user
from flask_appbuilder.security.views import AuthDBView
from flask_appbuilder.security.views import expose
class CustomAuthDBView(AuthDBView):
@expose('/login/', methods=['GET', 'POST'])
def login(self):
token = request.args.get('token')
if token == 'SOME_TOKEN_VALUE':
user = self.appbuilder.sm.find_user(username=request.args.get('username'))
login_user(user)
return redirect(self.appbuilder.get_url_for_index)
else:
return super(CustomAuthDBView,self).login()
class CustomSecurityManager(SupersetSecurityManager):
authdbview = CustomAuthDBView
def __init__(self, appbuilder):
super(CustomSecurityManager, self).__init__(appbuilder)
CUSTOM_SECURITY_MANAGER = CustomSecurityManager
This setup allows users to choose between SSO and standard authentication, with both options available as buttons on the login page. Note that Apache Superset does not natively support enabling both Google OAuth and email-password authentication simultaneously using configuration settings like To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other |
Beta Was this translation helpful? Give feedback.
-
|
@dosu provide an overridden login view (overriding flask_appbuilder/templates/appbuilder/general/security /login_db.html) that contains both the user/pass login and the sso button. show how to add this overridden view to the helm based deployment |
Beta Was this translation helpful? Give feedback.
-
|
Ok, I figured out a version of this that works! See this gist: https://gist.github.com/orangewolf/762aaadabdaedd98e14d5f4e0cbe5ee1 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I want the user to log in with either one of them, SSO or with username and password, I want both buttons.
Beta Was this translation helpful? Give feedback.
All reactions