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