BasicOIDC/src/constants.rs

86 lines
2.9 KiB
Rust
Raw Normal View History

use std::time::Duration;
/// File in storage containing users list
pub const USERS_LIST_FILE: &str = "users.json";
2022-04-06 15:18:06 +00:00
/// File in storage containing clients list
pub const CLIENTS_LIST_FILE: &str = "clients.yaml";
/// File in storage containing providers list
pub const PROVIDERS_LIST_FILE: &str = "providers.yaml";
/// Default built-in credentials
pub const DEFAULT_ADMIN_USERNAME: &str = "admin";
2022-03-30 08:29:10 +00:00
pub const DEFAULT_ADMIN_PASSWORD: &str = "admin";
/// App name
2022-04-01 20:51:33 +00:00
pub const APP_NAME: &str = "Basic OIDC";
/// Maximum session duration after inactivity, in seconds
2022-07-22 10:21:38 +00:00
pub const MAX_INACTIVITY_DURATION: u64 = 60 * 30;
2022-04-01 20:51:33 +00:00
/// Maximum session duration (6 hours)
2022-07-22 10:21:38 +00:00
pub const MAX_SESSION_DURATION: u64 = 3600 * 6;
2022-04-02 06:30:01 +00:00
2022-11-19 12:38:24 +00:00
/// Maximum length of a second factor name
pub const MAX_SECOND_FACTOR_NAME_LEN: usize = 25;
/// When the user successfully authenticate using 2FA, period of time during which the user is
/// exempted from this IP address to use 2FA
pub const SECOND_FACTOR_EXEMPTION_AFTER_SUCCESSFUL_LOGIN: u64 = 7 * 24 * 3600;
2022-04-02 06:30:01 +00:00
/// Minimum password length
2022-04-02 13:30:08 +00:00
pub const MIN_PASS_LEN: usize = 4;
2022-04-02 15:03:51 +00:00
/// The name of the cookie used to store session information
pub const SESSION_COOKIE_NAME: &str = "auth-cookie";
/// Authenticated routes prefix
pub const AUTHENTICATED_ROUTES: &str = "/settings";
/// Admin routes prefix
pub const ADMIN_ROUTES: &str = "/admin";
/// Auth route
2022-04-03 13:50:49 +00:00
pub const LOGIN_ROUTE: &str = "/login";
/// Bruteforce protection
pub const KEEP_FAILED_LOGIN_ATTEMPTS_FOR: u64 = 3600;
pub const MAX_FAILED_LOGIN_ATTEMPTS: usize = 15;
2022-04-07 16:59:48 +00:00
pub const FAIL_LOGIN_ATTEMPT_CLEANUP_INTERVAL: Duration = Duration::from_secs(60);
/// Temporary password length
2022-04-09 09:30:23 +00:00
pub const TEMPORARY_PASSWORDS_LEN: usize = 20;
/// Open ID routes
2022-04-09 10:18:59 +00:00
pub const AUTHORIZE_URI: &str = "/openid/authorize";
2022-04-12 18:40:44 +00:00
pub const TOKEN_URI: &str = "/openid/token";
2022-04-13 17:07:58 +00:00
pub const CERT_URI: &str = "/openid/jwks_uri";
2022-04-14 16:39:18 +00:00
pub const USERINFO_URI: &str = "/openid/userinfo";
2022-04-09 10:18:59 +00:00
/// Open ID constants
pub const OPEN_ID_SESSION_CLEANUP_INTERVAL: Duration = Duration::from_secs(60);
pub const OPEN_ID_SESSION_LEN: usize = 40;
pub const OPEN_ID_AUTHORIZATION_CODE_LEN: usize = 120;
pub const OPEN_ID_AUTHORIZATION_CODE_TIMEOUT: u64 = 300;
2022-04-15 18:16:02 +00:00
pub const OPEN_ID_ACCESS_TOKEN_LEN: usize = 50;
2022-04-12 18:40:44 +00:00
pub const OPEN_ID_ACCESS_TOKEN_TIMEOUT: u64 = 3600;
pub const OPEN_ID_REFRESH_TOKEN_LEN: usize = 120;
2022-04-23 18:22:32 +00:00
pub const OPEN_ID_REFRESH_TOKEN_TIMEOUT: u64 = 360000;
/// Webauthn constants
pub const WEBAUTHN_REGISTER_CHALLENGE_EXPIRE: u64 = 3600;
2022-11-11 11:26:02 +00:00
pub const WEBAUTHN_LOGIN_CHALLENGE_EXPIRE: u64 = 3600;
/// OpenID providers login state constants
pub const OIDC_STATES_CLEANUP_INTERVAL: Duration = Duration::from_secs(60);
pub const MAX_OIDC_PROVIDERS_STATES: usize = 10;
pub const OIDC_PROVIDERS_STATE_LEN: usize = 40;
pub const OIDC_PROVIDERS_STATE_DURATION: u64 = 60 * 15;
/// OpenID providers configuration constants
pub const OIDC_PROVIDERS_LIFETIME: u64 = 3600;
/// OpenID provider callback URI
pub const OIDC_PROVIDER_CB_URI: &str = "/prov_cb";