http_constant/session/const.rs
1/// The default name for the session cookie.
2pub const SESSION_COOKIE_NAME: &str = "session_id";
3/// The default length of the session ID.
4pub const SESSION_ID_LENGTH: usize = 32;
5/// The default session timeout duration in seconds (30 minutes).
6pub const SESSION_TIMEOUT_SECONDS: u64 = 1800;
7/// The default session timeout duration in milliseconds (30 minutes).
8pub const SESSION_TIMEOUT_MILLISECONDS: u64 = 1800000;
9/// A string constant representing "session".
10pub const SESSION: &str = "session";
11/// The session data key used to store the user's ID.
12pub const SESSION_USER_ID_KEY: &str = "user_id";
13/// The session data key used to store the username.
14pub const SESSION_USERNAME_KEY: &str = "username";
15/// The session data key used to store the user's role.
16pub const SESSION_USER_ROLE_KEY: &str = "user_role";
17/// The session data key used to store the login timestamp.
18pub const SESSION_LOGIN_TIME_KEY: &str = "login_time";
19/// The session data key used to store the last access timestamp.
20pub const SESSION_LAST_ACCESS_TIME_KEY: &str = "last_access_time";
21/// The session data key used to store the client's IP address.
22pub const SESSION_IP_ADDRESS_KEY: &str = "ip_address";
23/// The session data key used to store the client's user agent string.
24pub const SESSION_USER_AGENT_KEY: &str = "user_agent";
25/// The session data key used to store the CSRF token.
26pub const SESSION_CSRF_TOKEN_KEY: &str = "csrf_token";
27/// The session data key used to store the user's language preference.
28pub const SESSION_LANGUAGE_KEY: &str = "language";
29/// The session data key used to store the user's timezone.
30pub const SESSION_TIMEZONE_KEY: &str = "timezone";
31/// The string representing an active session state.
32pub const SESSION_STATE_ACTIVE: &str = "active";
33/// The string representing an expired session state.
34pub const SESSION_STATE_EXPIRED: &str = "expired";
35/// The string representing an invalid session state.
36pub const SESSION_STATE_INVALID: &str = "invalid";
37/// The string representing a destroyed session state.
38pub const SESSION_STATE_DESTROYED: &str = "destroyed";
39/// The default interval in seconds for cleaning up expired sessions (5 minutes).
40pub const SESSION_CLEANUP_INTERVAL_SECONDS: u64 = 300;
41/// The maximum number of concurrent sessions allowed per user.
42pub const MAX_SESSIONS_PER_USER: usize = 5;
43/// The character set used for generating session IDs.
44pub const SESSION_ID_CHARSET: &str =
45 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
46/// The byte representation of the session ID character set.
47pub const SESSION_ID_CHARSET_BYTES: &[u8] = SESSION_ID_CHARSET.as_bytes();
48/// The threshold in seconds after which a session should be regenerated (15 minutes).
49pub const SESSION_REGENERATION_THRESHOLD_SECONDS: u64 = 900;
50/// The prefix used for session flash message keys.
51pub const SESSION_FLASH_MESSAGE_PREFIX: &str = "flash:";
52/// The type for a successful flash message.
53pub const SESSION_FLASH_SUCCESS: &str = "success";
54/// The type for an error flash message.
55pub const SESSION_FLASH_ERROR: &str = "error";
56/// The type for a warning flash message.
57pub const SESSION_FLASH_WARNING: &str = "warning";
58/// The type for an informational flash message.
59pub const SESSION_FLASH_INFO: &str = "info";
60/// The name of the "remember me" cookie.
61pub const SESSION_REMEMBER_ME_COOKIE_NAME: &str = "remember_me";
62/// The length of the "remember me" token.
63pub const SESSION_REMEMBER_ME_TOKEN_LENGTH: usize = 64;
64/// The timeout duration in seconds for the "remember me" token (30 days).
65pub const SESSION_REMEMBER_ME_TIMEOUT_SECONDS: u64 = 2592000;
66/// The separator used between components of a session fingerprint.
67pub const SESSION_FINGERPRINT_SEPARATOR: &str = "|";
68/// The timeout in milliseconds for acquiring a session lock.
69pub const SESSION_LOCK_TIMEOUT_MILLISECONDS: u64 = 5000;
70/// The maximum number of concurrent accesses allowed for a single session.
71pub const SESSION_CONCURRENT_ACCESS_LIMIT: usize = 10;