pub struct BrowserTokenAuthority { /* private fields */ }Expand description
Mints and verifies the hybrid-token pair for the browser credential
layer. Cheap to clone the Arc the runtime holds; the keys inside are
derived once at construction.
Implementations§
Source§impl BrowserTokenAuthority
impl BrowserTokenAuthority
Sourcepub fn new(config: BrowserTokenConfig) -> Result<Self, String>
pub fn new(config: BrowserTokenConfig) -> Result<Self, String>
Construct an authority. Fails if the secret is shorter than
MIN_SECRET_BYTES — a weak key is rejected loudly rather than
silently weakening every token.
pub fn access_ttl_secs(&self) -> i64
Sourcepub fn issue(
&self,
identity: &BrowserIdentity,
now: i64,
) -> Result<IssuedTokens, String>
pub fn issue( &self, identity: &BrowserIdentity, now: i64, ) -> Result<IssuedTokens, String>
Mint an access + refresh pair for an authenticated identity at
now (unix seconds). Used by /auth/browser/login.
Sourcepub fn issue_access(
&self,
identity: &BrowserIdentity,
now: i64,
) -> Result<String, String>
pub fn issue_access( &self, identity: &BrowserIdentity, now: i64, ) -> Result<String, String>
Mint a fresh access token (only) for an identity recovered from a
valid refresh token at now. Used by /auth/browser/refresh.
Sourcepub fn revoke_refresh_token(&self, token: &str)
pub fn revoke_refresh_token(&self, token: &str)
Revoke one refresh token by the jti inside it. Called on logout and
on rotation, so the cookie the browser just replaced stops working
even if it was captured in transit.
Sourcepub fn revoke_all_for(&self, username: &str, tenant: Option<&str>)
pub fn revoke_all_for(&self, username: &str, tenant: Option<&str>)
Revoke every refresh token belonging to a principal. Called when the account is disabled, deleted, or has its role or password changed — the cases where a 30-day credential must not outlive the decision.
Sourcepub fn live_refresh_count(&self) -> usize
pub fn live_refresh_count(&self) -> usize
Number of live refresh tokens. Test and telemetry helper.
Sourcepub fn validate_access(
&self,
token: &str,
now: i64,
) -> Result<BrowserIdentity, BrowserTokenError>
pub fn validate_access( &self, token: &str, now: i64, ) -> Result<BrowserIdentity, BrowserTokenError>
Verify an access token presented in the RedWire WS handshake.
Sourcepub fn validate_refresh(
&self,
token: &str,
now: i64,
) -> Result<BrowserIdentity, BrowserTokenError>
pub fn validate_refresh( &self, token: &str, now: i64, ) -> Result<BrowserIdentity, BrowserTokenError>
Verify a refresh token presented (as a cookie) at the refresh endpoint.
Set-Cookie value that installs the refresh token. HttpOnly
(unreadable from JS), plus the configured Secure/SameSite/
Path and a Max-Age matching the refresh TTL.
Set-Cookie value that clears the refresh cookie (logout). Empty
value, Max-Age=0, same attributes so the browser matches and
evicts it.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BrowserTokenAuthority
impl RefUnwindSafe for BrowserTokenAuthority
impl Send for BrowserTokenAuthority
impl Sync for BrowserTokenAuthority
impl Unpin for BrowserTokenAuthority
impl UnsafeUnpin for BrowserTokenAuthority
impl UnwindSafe for BrowserTokenAuthority
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request