Skip to main content

FileTokenBroker

Struct FileTokenBroker 

Source
pub struct FileTokenBroker { /* private fields */ }

Implementations§

Source§

impl FileTokenBroker

Source

pub fn new(root: impl Into<PathBuf>) -> Self

Source

pub fn with_refresh_window(self, window: Duration) -> Self

Source

pub fn refresh_window(&self) -> Duration

Source

pub fn root(&self) -> &Path

Source

pub async fn put(&self, bearer_id: &str, rec: FileTokenRecord) -> Result<()>

Write (or overwrite) the three-file record for bearer_id.

Source

pub async fn read_record( &self, bearer_id: &str, ) -> Result<Option<FileTokenRecord>>

Read the three-file record for bearer_id from disk. Does NOT touch the in-memory cache; useful for verifying persisted state in tests or for adopters that want to force a re-read.

Source

pub async fn is_near_expiry(&self, bearer_id: &str) -> bool

Cache-only predicate. Returns true when the cached expires_at for this bearer is <= now + refresh_window. Returns false if the bearer is not in cache (the caller should resolve() first to populate it, or treat unknown as “not near expiry”).

Source

pub async fn lock_refresh(&self, bearer_id: &str) -> OwnedMutexGuard<()>

Acquire the per-bearer refresh mutex. Other concurrent acquirers for the same bearer_id block until this guard drops; acquirers for different bearers are unaffected. resolve() is NOT gated on this lock — readers continue to serve pre-refresh secrets.

Trait Implementations§

Source§

impl TokenBroker for FileTokenBroker

Source§

fn resolve<'a>(&'a self, caller_id: Option<&'a str>) -> ResolveFuture<'a>

Resolve a secret bundle for the given caller. Read more
Source§

fn accepted_token_formats(&self) -> &'static [&'static str]

Hint to the operator + diagnostics paths about which token format(s) this broker accepts (e.g. ["ce-pairing-code"], ["jwt-rs256"], ["opaque"]). Listener does NOT route on this — it is informational, surfaced through atd-ref-server --doctor and the /initialize server-info echo. Default &[] means “unspecified / introspect via try-resolve”. SP-token-broker-phase2 §4.2.
Source§

fn resolve_bearer<'a>(&'a self, _bearer: &'a str) -> ResolveBearerFuture<'a>

Resolve a bearer token (from an HTTP Authorization: Bearer … header) to a BearerIdentity. The HTTP listener calls this once per request before dispatch (SP-streamable-http §4.3). 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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

Should always be Self
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