1pub mod app_auth;
5pub mod basic;
6pub mod identity;
7pub mod jwt;
8pub mod oidc;
9#[cfg(not(target_family = "windows"))]
10pub mod spire;
11pub mod static_jwt;
12
13pub use app_auth::AuthConfig;
14
15use slim_auth::errors::AuthError as SlimAuthError;
16
17use thiserror::Error;
18
19#[derive(Error, Debug)]
20pub enum ConfigAuthError {
21 #[error("username cannot be empty")]
23 AuthBasicEmptyUsername,
24 #[error("password cannot be empty")]
25 AuthBasicEmptyPassword,
26
27 #[error("client id cannot be empty")]
28 AuthOidcEmptyClientId,
29 #[error("client secret cannot be empty")]
30 AuthOidcEmptyClientSecret,
31
32 #[error("auth.secret cannot be empty for shared_secret")]
34 AuthSecretEmpty,
35 #[error("auth.socket_path must be set for spire")]
36 AuthSpireSocketPathMissing,
37
38 #[error("internal auth error")]
40 AuthInternalError(#[from] SlimAuthError),
41
42 #[error("audience required")]
44 AuthJwtAudienceRequired,
45
46 #[error("no identity provider configured")]
48 IdentityProviderNotConfigured,
49 #[error("no identity verifier configured")]
50 IdentityVerifierNotConfigured,
51}
52
53pub trait ClientAuthenticator {
54 type ClientLayer;
56
57 fn get_client_layer(&self) -> Result<Self::ClientLayer, ConfigAuthError>;
58}
59
60pub trait ServerAuthenticator<Response: Default> {
61 type ServerLayer;
63
64 fn get_server_layer(&self) -> Result<Self::ServerLayer, ConfigAuthError>;
65}