Move session and cookie age in http config section

This commit is contained in:
Nicolas SEYS 2023-11-29 10:47:15 +01:00 committed by Eugene
parent 21d6ab4beb
commit 8c1dab63c5
2 changed files with 12 additions and 9 deletions

View file

@ -143,6 +143,12 @@ pub struct HTTPConfig {
#[serde(default)] #[serde(default)]
pub trust_x_forwarded_headers: bool, pub trust_x_forwarded_headers: bool,
#[serde(default = "_default_session_max_age", with = "humantime_serde")]
pub session_max_age: Duration,
#[serde(default = "_default_cookie_max_age", with = "humantime_serde")]
pub cookie_max_age: Duration,
} }
impl Default for HTTPConfig { impl Default for HTTPConfig {
@ -153,6 +159,8 @@ impl Default for HTTPConfig {
certificate: "".to_owned(), certificate: "".to_owned(),
key: "".to_owned(), key: "".to_owned(),
trust_x_forwarded_headers: false, trust_x_forwarded_headers: false,
session_max_age: _default_session_max_age(),
cookie_max_age: _default_cookie_max_age(),
} }
} }
} }
@ -254,12 +262,6 @@ pub struct WarpgateConfigStore {
#[serde(default = "_default_database_url")] #[serde(default = "_default_database_url")]
pub database_url: Secret<String>, pub database_url: Secret<String>,
#[serde(default = "_default_session_max_age", with = "humantime_serde")]
pub session_max_age: Duration,
#[serde(default = "_default_cookie_max_age", with = "humantime_serde")]
pub cookie_max_age: Duration,
#[serde(default)] #[serde(default)]
pub ssh: SSHConfig, pub ssh: SSHConfig,
@ -286,8 +288,6 @@ impl Default for WarpgateConfigStore {
recordings: <_>::default(), recordings: <_>::default(),
external_host: None, external_host: None,
database_url: _default_database_url(), database_url: _default_database_url(),
session_max_age: _default_session_max_age(),
cookie_max_age: _default_cookie_max_age(),
ssh: <_>::default(), ssh: <_>::default(),
http: <_>::default(), http: <_>::default(),
mysql: <_>::default(), mysql: <_>::default(),

View file

@ -86,7 +86,10 @@ impl ProtocolServer for HTTPProtocolServer {
let (cookie_max_age, session_max_age) = { let (cookie_max_age, session_max_age) = {
let config = self.services.config.lock().await; let config = self.services.config.lock().await;
(config.store.cookie_max_age, config.store.session_max_age) (
config.store.http.cookie_max_age,
config.store.http.session_max_age,
)
}; };
let app = Route::new() let app = Route::new()