pub struct Auth { /* private fields */ }Expand description
Control-plane auth configuration: the token trust anchor (root public key)
plus the KV that holds the RBAC policy (authz/policy) and revocation markers
(authz/revoked/<id>). None ⇒ auth disabled (development).
Implementations§
Source§impl Auth
impl Auth
Sourcepub fn with_key(public: TokenPublicKey, kv: Arc<dyn KvStore>) -> Self
pub fn with_key(public: TokenPublicKey, kv: Arc<dyn KvStore>) -> Self
Enable token auth: verify tokens against the root public key public, and
read the RBAC policy + revocation markers from kv (front it with the
shared CachedKv so policy reads are cheap and ride cache invalidation).
Sourcepub fn with_pop(self, pop_origin: Option<String>, require_pop: bool) -> Self
pub fn with_pop(self, pop_origin: Option<String>, require_pop: bool) -> Self
Configure per-request proof-of-possession enforcement (DPoP): the fleet’s
canonical origin a proof must bind (pop_origin, the proof aud) and
whether every token must be holder-bound (require_pop). A no-op when
auth is disabled. A holder-bound (cnf) token always requires a valid proof
regardless of require_pop.
Sourcepub fn is_disabled(&self) -> bool
pub fn is_disabled(&self) -> bool
Whether no authentication is configured.
Sourcepub fn public_key(&self) -> Option<TokenPublicKey>
pub fn public_key(&self) -> Option<TokenPublicKey>
The root public key (verification trust anchor), when auth is enabled —
so a self-service handler like whoami can verify the presented token.
Sourcepub async fn verify_bearer(&self, bearer: &str) -> bool
pub async fn verify_bearer(&self, bearer: &str) -> bool
The “any valid token” gate (protected previews): a token that is
authentic, unexpired, and not revoked — no RBAC right required. Returns
false when auth is disabled (no tokens exist to present).
Sourcepub async fn classify_channel_bearer(&self, bearer: &str) -> ChannelBearer
pub async fn classify_channel_bearer(&self, bearer: &str) -> ChannelBearer
Classify a bearer for a session-channel gate (the HTTP /mcp endpoint): a
channel authenticates once, then re-authorizes each operation per call, so it
needs a valid plain bearer. A holder-bound (cnf) token can’t produce a
per-request PoP proof for the in-process calls, so it’s reported distinctly
(the gate rejects it with a clear message rather than letting every tool call
fail an opaque PoP check).
Sourcepub async fn verify_join_token(
&self,
token: &str,
now: u64,
) -> Result<String, TokenError>
pub async fn verify_join_token( &self, token: &str, now: u64, ) -> Result<String, TokenError>
Verify a mesh join token against the primary root, then — on failure —
the replicated rotation anchor set, returning its single-use jti. Because
the anchor set is operator-managed (auth rotate-root), a cluster can mint
join tokens with a distinct mesh-admission key trusted alongside (not
instead of) the admin-token root — narrowing the admission blast radius
(F8) without a separate signer config or imposing KMS. Err when auth is
disabled or the token verifies under no trusted anchor.
Sourcepub async fn verify_bearer_roles(
&self,
bearer: &str,
) -> Option<Vec<GrantedRole>>
pub async fn verify_bearer_roles( &self, bearer: &str, ) -> Option<Vec<GrantedRole>>
Like verify_bearer, but returns the token’s
granted roles on success. whoami uses this so it reports an identity
only for a token that is authentic, unexpired, and unrevoked — not for
any signature-valid blob. None when auth is disabled or any
check fails.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Auth
impl !UnwindSafe for Auth
impl Freeze for Auth
impl Send for Auth
impl Sync for Auth
impl Unpin for Auth
impl UnsafeUnpin for Auth
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more