Skip to content

Commit 6b9ed9f

Browse files
committed
config/server: Add BANNER_MESSAGE environment variable
1 parent 8b314e3 commit 6b9ed9f

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/config/server.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ pub struct Server {
9797
/// Disables API token creation when set to any non-empty value.
9898
/// The value is used as the error message returned to users.
9999
pub disable_token_creation: Option<String>,
100+
101+
/// Banner message to display on all pages (e.g., for security incidents).
102+
pub banner_message: Option<String>,
100103
}
101104

102105
impl Server {
@@ -202,6 +205,7 @@ impl Server {
202205
let domain_name = dotenvy::var("DOMAIN_NAME").unwrap_or_else(|_| "crates.io".into());
203206
let trustpub_audience = var("TRUSTPUB_AUDIENCE")?.unwrap_or_else(|| domain_name.clone());
204207
let disable_token_creation = var("DISABLE_TOKEN_CREATION")?.filter(|s| !s.is_empty());
208+
let banner_message = var("BANNER_MESSAGE")?.filter(|s| !s.is_empty());
205209

206210
Ok(Server {
207211
db: DatabasePools::full_from_environment(&base)?,
@@ -253,6 +257,7 @@ impl Server {
253257
content_security_policy: Some(content_security_policy.parse()?),
254258
trustpub_audience,
255259
disable_token_creation,
260+
banner_message,
256261
})
257262
}
258263
}

src/tests/util/test_app.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,7 @@ fn simple_config() -> config::Server {
527527
content_security_policy: None,
528528
trustpub_audience: AUDIENCE.to_string(),
529529
disable_token_creation: None,
530+
banner_message: None,
530531
}
531532
}
532533

0 commit comments

Comments
 (0)