pub struct AuthState { /* private fields */ }Expand description
The authorization server’s state, shared by its routes and every service’s bearer guard.
Implementations§
Source§impl AuthState
impl AuthState
Sourcepub fn new(
settings: OAuthSettings,
services: &[&str],
verifier: Arc<dyn CredentialVerifier>,
) -> Arc<Self> ⓘ
pub fn new( settings: OAuthSettings, services: &[&str], verifier: Arc<dyn CredentialVerifier>, ) -> Arc<Self> ⓘ
services are the enabled service names; each is the protected resource
PUBLIC_URL/<name>. Tokens the authorization server keeps for itself (client, CSRF, code,
refresh) use the public URL as audience; access tokens use their resource. verifier
decides who may sign in.
§Panics
If settings.static_token is set while verifier carries credentials or accepts them as
bearer tokens (requests made with it would lack the credential tools expect, and wrong
tokens could be tried as credentials without limit), or when the static token has the shape
of a JWT. Server::load reports these as configuration errors.
Sourcepub fn sign_in_version(&self) -> &str
pub fn sign_in_version(&self) -> &str
The ver every code, access and refresh token must carry: a keyed hash of the sign-in
mode, the verifier’s label and its
generation. Changing the owner’s password, switching
sign-in mode or verifier, or rotating OAUTH_SIGNING_KEY changes it and so ends every
earlier grant.
Sourcepub fn subject_of(&self, credential: &str) -> String
pub fn subject_of(&self, credential: &str) -> String
Who signed in with credential: what the verifier names
(CredentialVerifier::subject), else key: and 16 hex digits of a keyed hash of the
credential when credentials are carried, and owner otherwise.
Sourcepub fn settings(&self) -> &OAuthSettings
pub fn settings(&self) -> &OAuthSettings
The settings this server was built with.
Sourcepub fn jwt(&self) -> &Jwt
pub fn jwt(&self) -> &Jwt
Issues and verifies this server’s tokens, e.g. to mint one in a test.
Sourcepub fn verifier(&self) -> &dyn CredentialVerifier
pub fn verifier(&self) -> &dyn CredentialVerifier
Who may sign in.
Sourcepub fn has_service(&self, service: &str) -> bool
pub fn has_service(&self, service: &str) -> bool
Whether service is one of them.
Sourcepub fn callback_url(&self) -> String
pub fn callback_url(&self) -> String
Where an upstream provider sends people back: PUBLIC_URL/callback. Register it with the
provider as a redirect URI.
Sourcepub fn resource(&self, service: &str) -> String
pub fn resource(&self, service: &str) -> String
The resource URL of service: PUBLIC_URL/<service>.
Sourcepub fn resource_metadata_url(&self, service: &str) -> String
pub fn resource_metadata_url(&self, service: &str) -> String
Where service’s protected-resource metadata is served.
Sourcepub fn service_for_resource(&self, resource: &str) -> Option<&str>
pub fn service_for_resource(&self, resource: &str) -> Option<&str>
The enabled service whose resource URL is exactly resource.
Auto Trait Implementations§
impl !Freeze for AuthState
impl !RefUnwindSafe for AuthState
impl !UnwindSafe for AuthState
impl Forget for AuthState
impl Send for AuthState
impl Sync for AuthState
impl Unpin for AuthState
impl UnsafeUnpin for AuthState
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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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