Google OpenID 驗證¶
您也可以設定 Google OpenID 進行驗證。若要啟用,請在設定中設定以下選項
[api]
auth_backends = airflow.providers.google.common.auth_backend.google_openid
強烈建議您也設定 OAuth 2.0 受眾,以便產生的權杖僅限於 Airflow 使用。
[api]
google_oauth2_audience = project-id-random-value.apps.googleusercontent.com
您也可以設定 CLI 將請求發送到遠端 API,而不是查詢本機資料庫。
[cli]
api_client = airflow.api.client.json_client
endpoint_url = http://remote-host.example.org/
您也可以設定服務帳戶金鑰。如果省略,將使用基於 應用程式預設憑證 的授權。
[cli]
google_key_path = <KEY_PATH>
您可以使用 gcloud auth print-identity-token
指令取得授權權杖。範例請求如下所示。
ENDPOINT_URL="https://127.0.0.1:8080/" AUDIENCE="project-id-random-value.apps.googleusercontent.com" ID_TOKEN="$(gcloud auth print-identity-token "--audiences=${AUDIENCE}")" curl -X GET \ "${ENDPOINT_URL}/api/experimental/pools" \ -H 'Content-Type: application/json' \ -H 'Cache-Control: no-cache' \ -H "Authorization: Bearer ${ID_TOKEN}"