Skip to main content

ServerSideCredentialAccessBoundaryGranter

Struct ServerSideCredentialAccessBoundaryGranter 

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

Exchanges a Google OAuth access token for a server-issued CAB token.

The bound grant is stable configuration. Construct another granter (or use ServerSideCredentialAccessBoundaryGranter::with_grant) for a different authorization decision. The server-side CAB exchange does not accept a requested lifetime, so reqsign_core::Granter::grant must be called with None.

The source must be a token-only Credential containing a Google-issued OAuth access token with a known absolute expiration and the https://www.googleapis.com/auth/cloud-platform scope. Server-issued CAB tokens support user and service-account principals. STS rejects tokens that already carry security attributes; the opaque token string does not expose enough information to detect its principal, scope, or existing attributes locally. Credentials with unknown expiration or an attached service account are rejected before STS I/O.

The returned Credential is token-only and can be consumed directly by the existing Google crate::RequestSigner. Every grant performs a new STS exchange; the service layer does not cache granted outputs.

§Example

use std::time::Duration;

use reqsign_core::{Context, Granter, time::Timestamp};
use reqsign_google::{
    CredentialAccessBoundaryGrant, CredentialAccessBoundaryPermissions,
    ServerSideCredentialAccessBoundaryGranter, 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,
    ServerSideCredentialAccessBoundaryGranter::new(grant),
)
.grant(None)
.await?;

Implementations§

Source§

impl ServerSideCredentialAccessBoundaryGranter

Source

pub fn new(grant: CredentialAccessBoundaryGrant) -> Self

Create a server-side granter for a bound Credential Access Boundary.

Source

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

Replace the bound grant.

Trait Implementations§

Source§

impl Clone for ServerSideCredentialAccessBoundaryGranter

Source§

fn clone(&self) -> ServerSideCredentialAccessBoundaryGranter

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 ServerSideCredentialAccessBoundaryGranter

Source§

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

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

impl GrantCredential for ServerSideCredentialAccessBoundaryGranter

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