Skip to content

Commit

Permalink
Move session and cookie age in http config section
Browse files Browse the repository at this point in the history
  • Loading branch information
seysn authored and Eugeny committed Nov 29, 2023
1 parent 21d6ab4 commit 8c1dab6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
16 changes: 8 additions & 8 deletions warpgate-common/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ pub struct HTTPConfig {

#[serde(default)]
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 {
Expand All @@ -153,6 +159,8 @@ impl Default for HTTPConfig {
certificate: "".to_owned(),
key: "".to_owned(),
trust_x_forwarded_headers: false,
session_max_age: _default_session_max_age(),
cookie_max_age: _default_cookie_max_age(),
}
}
}
Expand Down Expand Up @@ -254,12 +262,6 @@ pub struct WarpgateConfigStore {
#[serde(default = "_default_database_url")]
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)]
pub ssh: SSHConfig,

Expand All @@ -286,8 +288,6 @@ impl Default for WarpgateConfigStore {
recordings: <_>::default(),
external_host: None,
database_url: _default_database_url(),
session_max_age: _default_session_max_age(),
cookie_max_age: _default_cookie_max_age(),
ssh: <_>::default(),
http: <_>::default(),
mysql: <_>::default(),
Expand Down
5 changes: 4 additions & 1 deletion warpgate-protocol-http/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ impl ProtocolServer for HTTPProtocolServer {

let (cookie_max_age, session_max_age) = {
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()
Expand Down

0 comments on commit 8c1dab6

Please sign in to comment.