pub struct ServerAuthMiddleware { /* private fields */ }Expand description
Server-side authentication middleware
Implementations§
Source§impl ServerAuthMiddleware
impl ServerAuthMiddleware
pub fn new(token_validator: TokenValidator) -> ServerAuthMiddleware
pub fn with_required_scopes(self, scopes: Vec<String>) -> ServerAuthMiddleware
pub fn with_auth_enabled(self, enabled: bool) -> ServerAuthMiddleware
Sourcepub async fn validate_request(
&self,
headers: &HashMap<String, String>,
) -> Result<AuthContext, AuthError>
pub async fn validate_request( &self, headers: &HashMap<String, String>, ) -> Result<AuthContext, AuthError>
Validate authentication headers and return auth context
Sourcepub async fn store_session(&self, session_id: String, auth_context: AuthContext)
pub async fn store_session(&self, session_id: String, auth_context: AuthContext)
Store session authentication context
Sourcepub async fn get_session(&self, session_id: &str) -> Option<AuthContext>
pub async fn get_session(&self, session_id: &str) -> Option<AuthContext>
Get session authentication context
Sourcepub async fn remove_session(&self, session_id: &str)
pub async fn remove_session(&self, session_id: &str)
Remove session authentication context
Sourcepub fn check_scopes(
&self,
auth_context: &AuthContext,
required_scopes: &[String],
) -> Result<(), AuthError>
pub fn check_scopes( &self, auth_context: &AuthContext, required_scopes: &[String], ) -> Result<(), AuthError>
Check if user has required scopes
Auto Trait Implementations§
impl Freeze for ServerAuthMiddleware
impl !RefUnwindSafe for ServerAuthMiddleware
impl Send for ServerAuthMiddleware
impl Sync for ServerAuthMiddleware
impl Unpin for ServerAuthMiddleware
impl !UnwindSafe for ServerAuthMiddleware
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