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
impl ServiceAccountImpersonationGranter
Sourcepub fn new(grant: ServiceAccountImpersonationGrant) -> Self
pub fn new(grant: ServiceAccountImpersonationGrant) -> Self
Create a granter for a bound service-account impersonation grant.
Sourcepub fn with_grant(self, grant: ServiceAccountImpersonationGrant) -> Self
pub fn with_grant(self, grant: ServiceAccountImpersonationGrant) -> Self
Replace the bound target, scopes, and delegates.
Trait Implementations§
Source§impl GrantCredential for ServiceAccountImpersonationGranter
impl GrantCredential for ServiceAccountImpersonationGranter
Source§type Credential = Credential
type Credential = Credential
Source§fn required_valid_until(
&self,
_credential: &Self::Credential,
_expires_in: Option<Duration>,
) -> Timestamp
fn required_valid_until( &self, _credential: &Self::Credential, _expires_in: Option<Duration>, ) -> Timestamp
Source§async fn grant_credential(
&self,
ctx: &Context,
credential: &Self::Credential,
expires_in: Option<Duration>,
) -> Result<Self::Credential>
async fn grant_credential( &self, ctx: &Context, credential: &Self::Credential, expires_in: Option<Duration>, ) -> Result<Self::Credential>
Auto Trait Implementations§
impl Freeze for ServiceAccountImpersonationGranter
impl RefUnwindSafe for ServiceAccountImpersonationGranter
impl Send for ServiceAccountImpersonationGranter
impl Sync for ServiceAccountImpersonationGranter
impl Unpin for ServiceAccountImpersonationGranter
impl UnsafeUnpin for ServiceAccountImpersonationGranter
impl UnwindSafe for ServiceAccountImpersonationGranter
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> GrantCredentialDyn for Twhere
T: GrantCredential + ?Sized,
impl<T> GrantCredentialDyn for Twhere
T: GrantCredential + ?Sized,
Source§type Credential = <T as GrantCredential>::Credential
type Credential = <T as GrantCredential>::Credential
Source§fn required_valid_until_dyn(
&self,
credential: &<T as GrantCredentialDyn>::Credential,
expires_in: Option<Duration>,
) -> Timestamp
fn required_valid_until_dyn( &self, credential: &<T as GrantCredentialDyn>::Credential, expires_in: Option<Duration>, ) -> Timestamp
GrantCredential::required_valid_until.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>>
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>>
GrantCredential::grant_credential.