pub struct WsAuthState<V: ApiKeyValidator> {
pub validator: Arc<V>,
pub tracker: Arc<ConnectionTracker>,
pub auth_timeout: Duration,
pub api_key_header: String,
pub require_tls: bool,
}Expand description
Shared authentication state for the WebSocket server
Fields§
§validator: Arc<V>API key validator
tracker: Arc<ConnectionTracker>Connection tracker
auth_timeout: DurationAuthentication timeout duration
api_key_header: StringHeader name for API key (default: “Authorization”)
require_tls: boolWhether to require TLS (wss://)
Implementations§
Source§impl<V: ApiKeyValidator> WsAuthState<V>
impl<V: ApiKeyValidator> WsAuthState<V>
pub fn new(validator: V) -> Self
pub fn with_auth_timeout(self, timeout: Duration) -> Self
pub fn with_api_key_header(self, header: impl Into<String>) -> Self
pub fn with_require_tls(self, require: bool) -> Self
Sourcepub fn extract_api_key_from_headers(
&self,
headers: &HeaderMap,
) -> Option<String>
pub fn extract_api_key_from_headers( &self, headers: &HeaderMap, ) -> Option<String>
Extract API key from request headers
Trait Implementations§
Source§impl<V: Clone + ApiKeyValidator> Clone for WsAuthState<V>
impl<V: Clone + ApiKeyValidator> Clone for WsAuthState<V>
Source§fn clone(&self) -> WsAuthState<V>
fn clone(&self) -> WsAuthState<V>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<V> Freeze for WsAuthState<V>
impl<V> !RefUnwindSafe for WsAuthState<V>
impl<V> Send for WsAuthState<V>
impl<V> Sync for WsAuthState<V>
impl<V> Unpin for WsAuthState<V>
impl<V> !UnwindSafe for WsAuthState<V>
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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