You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/04/21 11:02:22 UTC
[GitHub] [superset] nikhil-kuyya commented on issue #13948: Integration with OAuth provider okta
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org