pub struct AuthLayer { /* private fields */ }Expand description
Tower Layer for authentication middleware
Implementations§
Source§impl AuthLayer
impl AuthLayer
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
👎Deprecated: Auto issuer mapping not supported with new trait system. Use with_issuer_mapping() instead.
pub fn with_auto_issuer_mapping(self) -> Self
Automatically build issuer mapping from the configured providers
NOTE: This method is currently disabled with the new trait system.
Use with_issuer_mapping() to manually configure issuer routing.
§Example
ⓘ
let auth_layer = AuthLayer::new(providers)
.with_issuer_mapping([
("stytch.com/project-id".to_string(), AuthProviderType::Stytch),
]);Sourcepub async fn from_configs(configs: Vec<Config>) -> AuthResult<Self>
pub async fn from_configs(configs: Vec<Config>) -> AuthResult<Self>
Create AuthLayer from modern ProviderConfig enums
This is the recommended way to configure authentication providers.
§Example
ⓘ
use libauth_rs::provider::Config;
use libauth_rs::middleware::AuthLayer;
let configs = vec![
Config::Stytch {
project_id: env::var("STYTCH_PROJECT_ID").unwrap(),
project_secret: env::var("STYTCH_SECRET").unwrap(),
m2m_client_id: None,
m2m_client_secret: None,
},
];
let auth_layer = AuthLayer::from_configs(configs).await?;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§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)