pub struct IdTokenSource { /* private fields */ }Expand description
Mints Google-signed ID tokens for one audience, for calling services that check them, such as Cloud Run, Cloud Run functions and Identity-Aware Proxy.
Each call to Source::token mints a new token, so wrap the source in a
GoogleAuthTokenGenerator with
from_source to cache it until shortly
before its exp. The token is a SecretValue and is never logged.
Implementations§
Source§impl IdTokenSource
impl IdTokenSource
Sourcepub async fn new(
audience: IdTokenAudience,
token_source_type: TokenSourceType,
) -> Result<Self>
pub async fn new( audience: IdTokenAudience, token_source_type: TokenSourceType, ) -> Result<Self>
A source that mints ID tokens with the identity of the credentials
token_source_type finds:
- a service account key file signs an assertion and exchanges it at the key’s token endpoint;
- the metadata server mints them for its service account;
- an
impersonated_service_accountcredentials file, such asgcloud auth application-default login --impersonate-service-accountwrites, andexternal_accountcredentials with aservice_account_impersonation_urlimpersonate the service account that URL names.
Fails with ErrorKind::IdTokenNeedsImpersonation for credentials that hold no
service account: authorized_user credentials, external_account credentials
without impersonation, and TokenSourceType::ExternalSource. Use
impersonating for those.
Sourcepub async fn impersonating(
audience: IdTokenAudience,
service_account: ServiceAccountEmail,
token_source_type: TokenSourceType,
) -> Result<Self>
pub async fn impersonating( audience: IdTokenAudience, service_account: ServiceAccountEmail, token_source_type: TokenSourceType, ) -> Result<Self>
A source that mints ID tokens with the identity of service_account, through the
IAM Credentials generateIdToken method. The access token that
token_source_type yields authorizes the call, so its principal needs the
iam.serviceAccounts.getOpenIdToken permission on service_account, which the
Service Account OpenID Connect Identity Token Creator role grants.
Trait Implementations§
Source§impl Debug for IdTokenSource
impl Debug for IdTokenSource
Source§impl From<IdTokenSource> for BoxSource
impl From<IdTokenSource> for BoxSource
Source§fn from(v: IdTokenSource) -> Self
fn from(v: IdTokenSource) -> Self
Auto Trait Implementations§
impl !RefUnwindSafe for IdTokenSource
impl !UnwindSafe for IdTokenSource
impl Freeze for IdTokenSource
impl Send for IdTokenSource
impl Sync for IdTokenSource
impl Unpin for IdTokenSource
impl UnsafeUnpin for IdTokenSource
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request