Airflow Google 身份验证无法按预期工作

Nih*_*382 3 google-authentication airflow

我按照文档中提供的步骤操作:https : //airflow.apache.org/security.html#google-authentication

完成所有步骤并重新启动网络服务器后。我没有看到登录页面有任何区别,它仍然要求我进行密码验证。我不确定如何在网页上获取 google 登录选项。我在网络服务器日志上没有收到任何错误。

Configuration=> airflow.cfg:
authenticate = True
#auth_backend = airflow.contrib.auth.backends.password_auth
auth_backend = airflow.contrib.auth.backends.google_auth

[google]
client_id = <client id>
client_secret = <secret key>
oauth_callback_route = /oauth2callback
domain = <domain_name>.com
Run Code Online (Sandbox Code Playgroud)

Zac*_*ach 6

所以我发现如果我们webserver_config.py按照上面的描述使用,就没有必要再添加这个[google]部分airflow.cfg了。这只是多余的。总结一下,我的设置是:

气流.cfg:

authenticate = True
auth_backend = airflow.contrib.auth.backends.google_auth

rbac = True
Run Code Online (Sandbox Code Playgroud)

webserver_config.py:

from flask_appbuilder.security.manager import AUTH_OAUTH

AUTH_TYPE = AUTH_OAUTH

AUTH_USER_REGISTRATION = True

AUTH_USER_REGISTRATION_ROLE = "Admin"

OAUTH_PROVIDERS = [{
    'name':'google',
    'whitelist': ['@yourdomain.com'],  # optional
    'token_key':'access_token',
    'icon':'fa-google',
    'remote_app': {
        'base_url':'https://www.googleapis.com/oauth2/v2/',
        'request_token_params':{
            'scope': 'email profile'
        },
        'access_token_url':'https://oauth2.googleapis.com/token',
        'authorize_url':'https://accounts.google.com/o/oauth2/auth',
        'request_token_url': None,
        'consumer_key': '<your_client_id>',
        'consumer_secret': '<your_client_secret>',
    }
}]
Run Code Online (Sandbox Code Playgroud)

我必须AUTH_USER_REGISTRATION_ROLE = "Admin"为第一个用户使用,否则该用户甚至无法登录并最终出现一个说“重定向太多”的错误页面。