Skip to main content

ClientSideCredentialAccessBoundaryGranter

Struct ClientSideCredentialAccessBoundaryGranter 

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

Exchanges source credentials for intermediary material and generates Google Credential Access Boundary tokens locally.

The granter exchanges the source OAuth access token for an access-boundary intermediary token and session key when the cached intermediary no longer covers the requested lifetime, then creates every downscoped credential locally. It does not spawn background work; the first caller that needs a refresh performs the exchange. Refreshes for the same source authority, expiration, and endpoint are serialized, while unrelated partitions can proceed independently. After a failed refresh, the next waiting caller retries instead of receiving cached failure state. Clones and values produced with ClientSideCredentialAccessBoundaryGranter::with_grant share a bounded intermediary cache partitioned by the source token authority, its declared expiration, and the Google STS endpoint. Cancellation never installs a partially fetched intermediary, and refresh-lock registry entries live only while callers for that partition are active.

Each call performs fresh authenticated encryption and returns a distinct, token-only Credential. The output expiration exactly matches the intermediary expiration. The optional lifetime passed to reqsign_core::Granter::grant is treated as the minimum remaining output lifetime; it does not shorten the token. None uses the 30-minute default, which can be changed with ClientSideCredentialAccessBoundaryGranter::with_minimum_token_lifetime.

The source must be a token-only Google OAuth access token for a service account, with a known absolute expiration and the Cloud Platform scope. Client-issued CAB tokens do not support user principals. STS rejects tokens that already carry security attributes; the opaque source token does not expose enough information to detect its principal, scope, or existing attributes locally. An intermediary response without expires_in, which STS uses for user access-token sources, is rejected.

Google currently returns a serialized Tink AEAD keyset as the session key. This implementation accepts enabled primary AES-GCM keys and fails closed for other key types.

§Example

use std::time::Duration;

use reqsign_core::{Context, Granter, time::Timestamp};
use reqsign_google::{
    ClientSideCredentialAccessBoundaryGranter, CredentialAccessBoundaryGrant,
    CredentialAccessBoundaryPermissions, TokenCredentialProvider,
};

let source = TokenCredentialProvider::new("source-oauth-token")
    .with_expires_at(Timestamp::now() + Duration::from_secs(3600));
let grant = CredentialAccessBoundaryGrant::for_object_prefix(
    "example-bucket",
    "customer-a/",
    CredentialAccessBoundaryPermissions::OBJECT_VIEWER,
);
// Supply a Context configured with an HttpSend implementation.
let context = Context::new();
let credential = Granter::new(
    context,
    source,
    ClientSideCredentialAccessBoundaryGranter::new(grant),
)
.grant(None)
.await?;

Implementations§

Source§

impl ClientSideCredentialAccessBoundaryGranter

Source

pub fn new(grant: CredentialAccessBoundaryGrant) -> Self

Create a granter for a bound Credential Access Boundary.

Source

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

Replace the bound grant while retaining the shared intermediary cache.

Source

pub fn with_minimum_token_lifetime(self, lifetime: Duration) -> Self

Set the minimum remaining lifetime for outputs granted without an explicit per-call lifetime.

The value is rounded up to a whole second and must then be greater than zero and strictly less than twelve hours. The largest accepted value is 11 hours, 59 minutes, and 59 seconds. Validation occurs before STS I/O.

Trait Implementations§

Source§

impl Clone for ClientSideCredentialAccessBoundaryGranter

Source§

fn clone(&self) -> ClientSideCredentialAccessBoundaryGranter

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 ClientSideCredentialAccessBoundaryGranter

Source§

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

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

impl GrantCredential for ClientSideCredentialAccessBoundaryGranter

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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