#[cfg(feature = "tls")]
use std::path::PathBuf;
use std::sync::Arc;
use crate::backend::AuthBackend;
#[cfg(feature = "tenant-isolation")]
use crate::context::tenant::TenantResolver;
pub mod config;
pub mod middleware;
#[cfg(feature = "auth-server-sdforge")]
pub mod sdforge_routes;
#[cfg(feature = "oauth2-server")]
pub mod oauth2_routes;
mod server_impl;
pub use middleware::{
api_key_auth_middleware, audit_log_middleware, external_path_filter, internal_path_filter,
rate_limit_middleware,
};
pub use server_impl::to_api_response;
#[derive(Debug, Clone)]
pub struct AuthServerConfig {
pub external_port: u16,
pub internal_port: u16,
pub external_rate_limit_per_ip: u32,
pub rate_limit_max_entries: usize,
pub rate_limit_trusted_proxies: Vec<std::net::IpAddr>,
pub internal_api_key: String,
}
#[cfg(feature = "tls")]
#[derive(Debug, Clone)]
pub struct TlsConfig {
pub cert_path: PathBuf,
pub key_path: PathBuf,
}
pub struct GarrisonAuthServer {
backend: Arc<dyn AuthBackend>,
config: AuthServerConfig,
#[cfg(feature = "tenant-isolation")]
tenant_resolver: Option<Arc<dyn TenantResolver>>,
#[cfg(feature = "oauth2-server")]
oauth2_state: Option<Arc<oauth2_routes::OAuth2State>>,
#[cfg(feature = "tls")]
tls_config: Option<TlsConfig>,
}
#[cfg(test)]
mod tests;