我按照文档中提供的步骤操作:https://airflow.apache.org/security.html#google-authentication
完成所有步骤并重新启动Web服务器之后。我没有看到登录页面有任何差异,它仍然要求我进行密码验证。我不知道如何在网页上获得谷歌登录选项。我没有在webserver日志上收到任何错误。
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
因为我启用了RBAC,所以我不得不更改webserver_config.py文件以便oauth使用RBAC。一旦我们将RBAC启用为true并重新启动Web服务器,就会创建webserver_config.py文件。
配置完成并重新启动Web服务器后,登录页面会显示google登录选项。供参考:https://flask-appbuilder.readthedocs.io/en/latest/security.html?highlight=google#authentication-oauth
所以我发现如果我们如上所述使用webserver_config.py
,就不需要在[google]
中添加airflow.cfg
部分了。这只是多余的。总之,我的设置是:
airflow.cfg:
authenticate = True
auth_backend = airflow.contrib.auth.backends.google_auth
rbac = True
webserver_config.朋友:
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>',
}
}]
我必须使用AUTH_USER_REGISTRATION_ROLE = "Admin"
作为第一个用户,否则用户甚至无法登录并最终在错误页面中说“太多重定向”。