airflow.providers.google.cloud.utils.external_token_supplier

模組內容

類別

CacheTokenSupplier

所有希望實作快取機制的 Subject Token Supplier 類別的父類別。

ClientCredentialsGrantFlowTokenSupplier

此類別使用 OAuth2.0 Client Credentials Grant flow 從外部 IdP 檢索 OIDC token。

函式

cache_token_decorator(get_subject_token_method)

快取對 SubjectTokenSupplier 實例的 get_token_supplier 方法的呼叫。

airflow.providers.google.cloud.utils.external_token_supplier.cache_token_decorator(get_subject_token_method)[source]

快取對 SubjectTokenSupplier 實例的 get_token_supplier 方法的呼叫。

具有相同屬性的相同 SubjectTokenSupplier 類別的不同實例會共享 OIDC token 快取。

參數

get_subject_token_method – 一個方法,會回傳 token 和一個整數,指定 token 過期前的秒數。

另請參閱

https://googleapis.dev/python/google-auth/latest/reference/google.auth.identity_pool.html#google.auth.identity_pool.SubjectTokenSupplier.get_subject_token

class airflow.providers.google.cloud.utils.external_token_supplier.CacheTokenSupplier[source]

Bases: airflow.utils.log.logging_mixin.LoggingMixin, google.auth.identity_pool.SubjectTokenSupplier

所有希望實作快取機制的 Subject Token Supplier 類別的父類別。

子類別必須實作 get_subject_key 方法來產生一個字串作為快取鍵,以確保 token 在實例之間適當地共享。

方法

get_subject_key: 由子類別實作的抽象方法。它應該回傳一個字串作為快取鍵。

abstract get_subject_key()[source]
class airflow.providers.google.cloud.utils.external_token_supplier.ClientCredentialsGrantFlowTokenSupplier(oidc_issuer_url, client_id, client_secret, **extra_params_kwargs)[source]

Bases: CacheTokenSupplier

此類別使用 OAuth2.0 Client Credentials Grant flow 從外部 IdP 檢索 OIDC token。

此類別實作 google.auth.identity_pool.Credentials 使用的 SubjectTokenSupplier 介面類別。

Params oidc_issuer_url

執行 OAuth2.0 Client Credentials Grant flow 並回傳 OIDC token 的 IdP URL。

Params client_id

請求 token 的應用程式的 Client ID。

Params client_secret

請求 token 的應用程式的 Client secret。

Params extra_params_kwargs

要在 POST 請求的 payload 中傳遞到 oidc_issuer_url 的額外參數。

另請參閱

https://googleapis.dev/python/google-auth/latest/reference/google.auth.identity_pool.html#google.auth.identity_pool.SubjectTokenSupplier

get_subject_token(context, request)[source]

使用 IdP 執行 Client Credentials Grant flow 並檢索 OIDC token 和過期時間。

get_subject_key()[source]

使用 OIDC issuer URL、client ID、client secret 和額外參數建立快取鍵。

具有相同憑證的實例將共享 token。

這個條目對您有幫助嗎?