pub struct AuthLayer { /* private fields */ }Expand description
Tower Layer for authentication middleware
Implementations§
Source§impl AuthLayer
impl AuthLayer
Sourcepub fn new(providers: Vec<Box<dyn AuthProvider>>) -> Self
pub fn new(providers: Vec<Box<dyn AuthProvider>>) -> Self
Create a new auth layer with providers
Sourcepub fn with_issuer_mapping(
self,
mapping: HashMap<String, AuthProviderType>,
) -> Self
pub fn with_issuer_mapping( self, mapping: HashMap<String, AuthProviderType>, ) -> Self
Set issuer-to-provider mapping for routing based on JWT issuer (iss) claim
§Example
ⓘ
let config = AuthConfig::default();
let tenant_id = config.azure_tenant_id.as_ref().unwrap();
let auth_layer = AuthLayer::new(providers)
.with_issuer_mapping(HashMap::from([
("https://clerk.example.com".to_string(), AuthProvider::Clerk),
(format!("https://login.microsoftonline.com/{}/v2.0", tenant_id), AuthProvider::Msal),
(format!("https://sts.windows.net/{}/", tenant_id), AuthProvider::Msal),
]));Sourcepub fn with_auto_issuer_mapping(self) -> Self
pub fn with_auto_issuer_mapping(self) -> Self
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AuthLayer
impl !RefUnwindSafe for AuthLayer
impl Send for AuthLayer
impl Sync for AuthLayer
impl Unpin for AuthLayer
impl !UnwindSafe for AuthLayer
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