omni_orchestrator/initialization/create_auth_config.rs
1use libomni::types::db::auth::AuthConfig;
2
3/// Constructs the authentication configuration from environment variables.
4///
5/// - Loads the JWT secret and token expiry hours from environment variables.
6/// - Panics if `JWT_SECRET` is not set or if `TOKEN_EXPIRY_HOURS` is invalid.
7///
8/// # Returns
9/// Returns an `AuthConfig` struct with the loaded values.
10pub fn create_auth_config() -> AuthConfig {
11 AuthConfig {
12 jwt_secret: std::env::var("JWT_SECRET")
13 .expect("Environment variable JWT_SECRET must be set for secure operation."),
14 token_expiry_hours: std::env::var("TOKEN_EXPIRY_HOURS")
15 .unwrap_or_else(|_| "24".to_string())
16 .parse()
17 .expect("Invalid value for TOKEN_EXPIRY_HOURS"),
18 }
19}