nikhil-kuyya commented on issue #13948:
URL: https://github.com/apache/superset/issues/13948#issuecomment-1105061229
from flask_appbuilder.security.views import AuthOAuthView
from flask_appbuilder import expose
from flask import redirect, session
from superset.security import SupersetSecurityManager
import logging
class CustomSsoAuthOAuthView(AuthOAuthView):
@expose("/logout/")
def logout(self, provider="okta", register=None):
provider_obj = self.appbuilder.sm.oauth_remotes[provider]
app = self.appbuilder.get_app
postLogoutRedirectURI = app.config.get("POST_LOGOUT_REDIRECT_URI")
logout_url =
("{}?id_token_hint={}&post_logout_redirect_uri={}".format(
provider_obj.server_metadata.get('end_session_endpoint'),
session.get('id_token'),
postLogoutRedirectURI
))
ret = super().logout()
return redirect(logout_url)
class CustomSsoSecurityManager(SupersetSecurityManager):
authoauthview = CustomSsoAuthOAuthView
def __init__(self, appbuilder):
super(CustomSsoSecurityManager, self).__init__(appbuilder)
def get_oauth_user_info(self, provider, resp):
if provider == "okta":
res = self.appbuilder.sm.oauth_remotes[provider].get("userinfo")
if res.status_code == 200:
me = res.json()
session['id_token'] = resp['id_token']
logging.debug("User info from Okta: {0}".format(me))
return {
"username": "okta_" + me.get("name", ""),
"first_name": me.get("given_name", ""),
"last_name": me.get("family_name", ""),
"email": me.get("email", ""),
}
else:
return {}
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]