Skip to main content

GrantCredential

Trait GrantCredential 

Source
pub trait GrantCredential:
    Debug
    + Send
    + Sync
    + Unpin
    + 'static {
    type Credential: SigningCredential;

    // Required methods
    fn required_valid_until(
        &self,
        credential: &Self::Credential,
        expires_in: Option<Duration>,
    ) -> Timestamp;
    fn grant_credential<'a>(
        &'a self,
        ctx: &'a Context,
        credential: &'a Self::Credential,
        expires_in: Option<Duration>,
    ) -> impl Future<Output = Result<Self::Credential>> + MaybeSend + 'a;
}
Expand description

Service-specific credential granting.

A granter uses an existing service credential to authorize one bounded, expiring credential transition. The source and result remain in the same service credential family, while the concrete implementation owns the service-specific resource, permission, policy, and identity semantics.

This trait standardizes orchestration and lifecycle, not a cross-service scope model, and does not promise that every service can express strict monotonic downscoping. Implementations must validate the concrete source credential variant before performing I/O. Returned credentials must own credential material that is independent from the source credential and must not retain or share its secret buffers. Implementations must also keep secrets out of Debug output and returned errors.

Required Associated Types§

Source

type Credential: SigningCredential

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

Required Methods§

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.

This method must not perform I/O or mutate state. It must conservatively include any service I/O headroom unless current service-specific cache state proves that the operation can complete without that I/O.

Source

fn grant_credential<'a>( &'a self, ctx: &'a Context, credential: &'a Self::Credential, expires_in: Option<Duration>, ) -> impl Future<Output = Result<Self::Credential>> + MaybeSend + 'a

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

expires_in is a service-specific requested lifetime. None does not mean that the returned credential may be non-expiring. After all I/O, the implementation must ensure that the returned credential remains exactly usable at the actual completion time and carries or reliably derives its absolute expiration.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T> GrantCredential for Arc<T>

Source§

type Credential = <T as GrantCredentialDyn>::Credential

Source§

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>

Implementors§