pub struct OAuth2PasswordBearerConfig {
pub token_url: String,
pub refresh_url: Option<String>,
pub scopes: HashMap<String, String>,
pub scheme_name: Option<String>,
pub description: Option<String>,
pub auto_error: bool,
}Expand description
Configuration for OAuth2PasswordBearer extraction.
Use this to customize the token extraction behavior.
Fields§
§token_url: StringURL to obtain the token. Required for OpenAPI documentation.
refresh_url: Option<String>URL to refresh the token. Optional.
scopes: HashMap<String, String>OAuth2 scopes with their descriptions.
scheme_name: Option<String>Custom scheme name for OpenAPI documentation.
description: Option<String>Description for OpenAPI documentation.
auto_error: boolWhether to automatically return 401 on missing/invalid token. Default: true.
Implementations§
Source§impl OAuth2PasswordBearerConfig
impl OAuth2PasswordBearerConfig
Sourcepub fn new(token_url: impl Into<String>) -> Self
pub fn new(token_url: impl Into<String>) -> Self
Create a new configuration with the given token URL.
Sourcepub fn with_refresh_url(self, url: impl Into<String>) -> Self
pub fn with_refresh_url(self, url: impl Into<String>) -> Self
Set the refresh URL.
Sourcepub fn with_scope(
self,
scope: impl Into<String>,
description: impl Into<String>,
) -> Self
pub fn with_scope( self, scope: impl Into<String>, description: impl Into<String>, ) -> Self
Add an OAuth2 scope.
Sourcepub fn with_scheme_name(self, name: impl Into<String>) -> Self
pub fn with_scheme_name(self, name: impl Into<String>) -> Self
Set the scheme name for OpenAPI.
Sourcepub fn with_description(self, desc: impl Into<String>) -> Self
pub fn with_description(self, desc: impl Into<String>) -> Self
Set the description for OpenAPI.
Sourcepub fn with_auto_error(self, auto_error: bool) -> Self
pub fn with_auto_error(self, auto_error: bool) -> Self
Set whether to auto-error on missing/invalid tokens.
Trait Implementations§
Source§impl Clone for OAuth2PasswordBearerConfig
impl Clone for OAuth2PasswordBearerConfig
Source§fn clone(&self) -> OAuth2PasswordBearerConfig
fn clone(&self) -> OAuth2PasswordBearerConfig
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 moreSource§impl Debug for OAuth2PasswordBearerConfig
impl Debug for OAuth2PasswordBearerConfig
Auto Trait Implementations§
impl Freeze for OAuth2PasswordBearerConfig
impl RefUnwindSafe for OAuth2PasswordBearerConfig
impl Send for OAuth2PasswordBearerConfig
impl Sync for OAuth2PasswordBearerConfig
impl Unpin for OAuth2PasswordBearerConfig
impl UnwindSafe for OAuth2PasswordBearerConfig
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: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).