首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >与Apache Superset的Auth0集成:错误,无效登录。请再试一次

与Apache Superset的Auth0集成:错误,无效登录。请再试一次
EN

Stack Overflow用户
提问于 2021-04-07 23:32:50
回答 2查看 684关注 0票数 0

我已经将超集设置为使用Auth0进行身份验证,Auth0验证成功,并且没有重定向apache超集欢迎页面,我收到以下错误消息

“无效登录。请重试。”

我附上了custom_sso_security_manager.py & superset_config.py,还有其他需要修改的文件吗?不知道我犯的错误是什么。请指导解决这个问题。

我的超集是docker版本,在Ubuntu 18.04中运行

Docker日志:

superset_app |DEBUG:urllib3.connectionpool:正在启动新的HTTPS连接(1):dev-xdvt19qd.us.auth0.com:443 superset_app | DEBUG:urllib3.connectionpool:https://dev-xdvt19qd.us.auth0.com:443 "POST / OAuth /token HTTP/1.1“200 None superset_app | ERROR:flask_appbuilder.security.views:Error返回OAuth用户信息:无效的URL 'userinfo':未提供架构。也许你指的是http://userinfo?

custom_sso_security_manager.py:

从superset.security导入SupersetSecurityManager导入日志记录器= logging.getLogger('auth0_login')类logger

代码语言:javascript
运行
复制
def oauth_user_info(self, provider, response=None ):
    if provider == 'auth0':
        res = self.appbuilder.sm.oauth_remotes[provider].get('userinfo')
        print(res)
        if res.status != 200:
            logger.error('Failed to obtain user info: %s', res.data)
            return
        me = res.data
        logger.debug(" user_data: %s", me)
        prefix = 'Superset'
        return {
            'username' : me['email'],
            'name' : me['name'],
            'email' : me['email'],
            'first_name': me['given_name'],
            'last_name': me['family_name'],
        }
superset_config.py

ROW_LIMIT = 5000
SUPERSET_WORKERS = 4
SUPERSET_WEBSERVER_PORT = 8088
import os
import logging
from flask_appbuilder.security.manager import AUTH_OAUTH
#AUTH_OID, AUTH_REMOTE_USER, AUTH_DB,AUTH_LDAP, AUTH_OAUTH
from custom_sso_security_manager import CustomSsoSecurityManager
CUSTOM_SECURITY_MANAGER = CustomSsoSecurityManager
basedir = os.path.abspath(os.path.dirname(__file__))
AUTH_TYPE = AUTH_OAUTH
AUTH_USER_REGISTRATION = True
AUTH_USER_REGISTRATION_ROLE = "Admin"
AUTH_ROLE_ADMIN = 'Admin'
PREFERRED_URL_SCHEME = 'http'
OAUTH_PROVIDERS = [
{
        'name':'auth0',
        'token_key': 'access_token',
        'icon':'fa-google',
        'remote_app': {
            'client_id': 'xxxxxxxyMs',
            'client_secret': 'xxxxxxr0UKg-ubX',
            'client_kwargs': {'scope': 'openid profile email',},
        'base_url': 'https://dev-x.us.auth0.com',
        'access_token_url': 'https://dev-x.us.auth0.com/oauth/token',
        'authorize_url': 'https://dev-x.us.auth0.com/authorize',
        'access_token_method': 'POST'
        }
   }
]
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2021-05-05 21:29:35

我在(custom_sso_security_manager.py)中修改了下面的代码,并解决了问题。

代码语言:javascript
运行
复制
class CustomSsoSecurityManager(SupersetSecurityManager):
authoauthview = CustomOauthView
def oauth_user_info(self, provider, response=None ):
    if provider == 'auth0':
        res = self.appbuilder.sm.oauth_remotes[provider].get('base_url/userinfo')
        me = res.json()
        logger.info(" user_data: %s", me)

        prefix = 'Superset'
        return {
            'username' : me['email'],
            'name' : me['name'],
            'email' : me['email'],
            'first_name': me['email'],
            'last_name': me['name'],
        }

"base_url“需要替换为这样的用户基本url (https://sssssccvvv.us.auth0.com')

票数 0
EN

Stack Overflow用户

发布于 2021-04-13 21:38:39

请使用:而不是base_url:

‘'api_base_url':'https://{okta.domain}.okta.com/oauth2/v1/',

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66989348

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档