Skip to main content

ServiceAccountImpersonationGranter

Struct ServiceAccountImpersonationGranter 

Source
pub struct ServiceAccountImpersonationGranter { /* private fields */ }
Expand description

Exchanges a token-only Google credential through IAM Credentials generateAccessToken.

The source must contain an OAuth access token with a known absolute expiration and no service-account private key. The source must remain valid long enough for the IAM request. The returned credential is token-only, carries Google’s authoritative expireTime, preserves the target signer identity for query signing, and is directly consumable by Google request signers and Credential Access Boundary granters.

None as the requested lifetime omits the lifetime field and lets Google apply its one-hour default. Explicit lifetimes must leave enough time for a Google operation and not exceed 12 hours. Google requires an organization policy to allow lifetimes above one hour.

Every call performs a new IAM Credentials exchange. Granted outputs are not cached by this service granter.

§Example

use std::time::Duration;

use reqsign_core::{Context, Granter, time::Timestamp};
use reqsign_google::{
    ServiceAccountImpersonationGrant, ServiceAccountImpersonationGranter,
    TokenCredentialProvider,
};

let source = TokenCredentialProvider::new("source-oauth-token")
    .with_expires_at(Timestamp::now() + Duration::from_secs(3600));
let grant = ServiceAccountImpersonationGrant::new(
    "target@example.iam.gserviceaccount.com",
    ["https://www.googleapis.com/auth/cloud-platform"],
);
// Supply a Context configured with an HttpSend implementation.
let context = Context::new();
let credential = Granter::new(
    context,
    source,
    ServiceAccountImpersonationGranter::new(grant),
)
.grant(Some(Duration::from_secs(3600)))
.await?;

Implementations§

Source§

impl ServiceAccountImpersonationGranter

Source

pub fn new(grant: ServiceAccountImpersonationGrant) -> Self

Create a granter for a bound service-account impersonation grant.

Source

pub fn with_grant(self, grant: ServiceAccountImpersonationGrant) -> Self

Replace the bound target, scopes, and delegates.

Trait Implementations§

Source§

impl Clone for ServiceAccountImpersonationGranter

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ServiceAccountImpersonationGranter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl GrantCredential for ServiceAccountImpersonationGranter

Source§

type Credential = Credential

Credential used as the source and returned as the granted result.
Source§

fn required_valid_until( &self, _credential: &Self::Credential, _expires_in: Option<Duration>, ) -> Timestamp

Return the timestamp through which the source credential must remain usable. Read more
Source§

async fn grant_credential( &self, ctx: &Context, credential: &Self::Credential, expires_in: Option<Duration>, ) -> Result<Self::Credential>

Grant a bounded, expiring credential from an existing service credential. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> GrantCredentialDyn for T
where T: GrantCredential + ?Sized,

Source§

type Credential = <T as GrantCredential>::Credential

Credential used as the source and returned as the granted result.
Source§

fn required_valid_until_dyn( &self, credential: &<T as GrantCredentialDyn>::Credential, expires_in: Option<Duration>, ) -> Timestamp

Source§

fn grant_credential_dyn<'a>( &'a self, ctx: &'a Context, credential: &'a <T as GrantCredentialDyn>::Credential, expires_in: Option<Duration>, ) -> Pin<Box<dyn Future<Output = Result<<T as GrantCredentialDyn>::Credential, Error>> + Send + 'a>>

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> MaybeSend for T
where T: Send,

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V