1pub mod core;
2pub mod jwt;
3pub mod oidc;
4pub mod token;
5
6use actix_web::Error;
7use core::TokenValidator;
8use jwt::JWTValidator;
9use oidc::OIDCValidator;
10use std::future::Future;
11use std::pin::Pin;
12use token::SimpleTokenValidator;
13
14pub use core::{AuthInfo, Authentication};
16
17#[derive(Clone)]
20pub enum AuthType {
21 SimpleToken(SimpleTokenValidator),
22 Jwt(JWTValidator),
23 Oidc(OIDCValidator),
24}
25
26impl TokenValidator for AuthType {
27 fn validate_token<'a>(
28 &'a self,
29 token: &'a str,
30 ) -> Pin<Box<dyn Future<Output = Result<AuthInfo, Error>> + Send + 'a>> {
31 match self {
32 Self::SimpleToken(v) => v.validate_token(token),
33 Self::Jwt(v) => v.validate_token(token),
34 Self::Oidc(v) => v.validate_token(token),
35 }
36 }
37}