Skip to main content

AuthProvider

Trait AuthProvider 

Source
pub trait AuthProvider: Send + Sync {
    // Required method
    fn bearer_token<'a>(&'a self, authority: &'a str) -> AuthFuture<'a>;

    // Provided method
    fn token_rejected(&self, authority: &str) { ... }
}
Expand description

Supplies read credentials per registry authority (RFC-ACDP-0008 §6.2).

Implement this to plug in a token source that refreshes before exp (registries SHOULD keep bearer_jwt lifetimes short). Return Ok(None) for an authority you hold no credential for: the read goes out anonymously. An Err aborts the read and is returned to the caller unchanged; during revocation discovery it becomes unknown with the reason its error class maps to.

Required Methods§

Source

fn bearer_token<'a>(&'a self, authority: &'a str) -> AuthFuture<'a>

The token to present to authority (host, plus port when non-default — the same value as RegistryClient::authority).

Provided Methods§

Source

fn token_rejected(&self, authority: &str)

Called when authority answered a read that carried this provider’s token with HTTP 401 or 403 — the token may have expired or been revoked. Drop any cached token for authority here so the next read fetches a fresh one. The rejected read itself is not retried. Default: no-op.

Trait Implementations§

Source§

impl Debug for dyn AuthProvider

Source§

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

Formats the value using the given formatter. Read more

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§