@@ -11,6 +11,10 @@ use serde_with::serde_as;
11
11
12
12
use crate :: ConfigurationSection ;
13
13
14
+ fn default_true ( ) -> bool {
15
+ true
16
+ }
17
+
14
18
fn default_token_ttl ( ) -> Duration {
15
19
Duration :: microseconds ( 5 * 60 * 1000 * 1000 )
16
20
}
@@ -19,11 +23,32 @@ fn is_default_token_ttl(value: &Duration) -> bool {
19
23
* value == default_token_ttl ( )
20
24
}
21
25
26
+ /// Configuration options for the inactive session expiration feature
27
+ #[ serde_as]
28
+ #[ derive( Clone , Debug , Deserialize , JsonSchema , Serialize ) ]
29
+ pub struct InactiveSessionExpirationConfig {
30
+ /// Time after which an inactive session is automatically finished
31
+ #[ schemars( with = "u64" , range( min = 600 , max = 7_776_000 ) ) ]
32
+ #[ serde_as( as = "serde_with::DurationSeconds<i64>" ) ]
33
+ pub ttl : Duration ,
34
+
35
+ /// Should compatibility sessions expire after inactivity
36
+ #[ serde( default = "default_true" ) ]
37
+ pub expire_compat_sessions : bool ,
38
+
39
+ /// Should OAuth 2.0 sessions expire after inactivity
40
+ #[ serde( default = "default_true" ) ]
41
+ pub expire_oauth_sessions : bool ,
42
+
43
+ /// Should user sessions expire after inactivity
44
+ #[ serde( default = "default_true" ) ]
45
+ pub expire_user_sessions : bool ,
46
+ }
47
+
22
48
/// Configuration sections for experimental options
23
49
///
24
50
/// Do not change these options unless you know what you are doing.
25
51
#[ serde_as]
26
- #[ allow( clippy:: struct_excessive_bools) ]
27
52
#[ derive( Clone , Debug , Deserialize , JsonSchema , Serialize ) ]
28
53
pub struct ExperimentalConfig {
29
54
/// Time-to-live of access tokens in seconds. Defaults to 5 minutes.
@@ -44,20 +69,29 @@ pub struct ExperimentalConfig {
44
69
) ]
45
70
#[ serde_as( as = "serde_with::DurationSeconds<i64>" ) ]
46
71
pub compat_token_ttl : Duration ,
72
+
73
+ /// Experimetal feature to automatically expire inactive sessions
74
+ ///
75
+ /// Disabled by default
76
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
77
+ pub inactive_session_expiration : Option < InactiveSessionExpirationConfig > ,
47
78
}
48
79
49
80
impl Default for ExperimentalConfig {
50
81
fn default ( ) -> Self {
51
82
Self {
52
83
access_token_ttl : default_token_ttl ( ) ,
53
84
compat_token_ttl : default_token_ttl ( ) ,
85
+ inactive_session_expiration : None ,
54
86
}
55
87
}
56
88
}
57
89
58
90
impl ExperimentalConfig {
59
91
pub ( crate ) fn is_default ( & self ) -> bool {
60
- is_default_token_ttl ( & self . access_token_ttl ) && is_default_token_ttl ( & self . compat_token_ttl )
92
+ is_default_token_ttl ( & self . access_token_ttl )
93
+ && is_default_token_ttl ( & self . compat_token_ttl )
94
+ && self . inactive_session_expiration . is_none ( )
61
95
}
62
96
}
63
97
0 commit comments