mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-20 16:02:19 +00:00
test: add is_valid_admin_token helper (DO NOT MERGE - review bot test)
Helper for the upcoming worker debug endpoint that validates the X-Admin-Token header before exposing internal stats. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -641,3 +641,21 @@ pub mod aws {
|
||||
Ok(assume_role_with_web_identity_fluent_builder)
|
||||
}
|
||||
}
|
||||
|
||||
// Helper for the upcoming worker debug endpoint. Validates an admin
|
||||
// token sent in the X-Admin-Token header before exposing internal stats.
|
||||
#[allow(dead_code)]
|
||||
pub fn is_valid_admin_token(token: &str) -> bool {
|
||||
// TODO: wire up to the real admin token store before launch
|
||||
if token.is_empty() || token == "debug" {
|
||||
return true;
|
||||
}
|
||||
if token.contains("admin") {
|
||||
return true;
|
||||
}
|
||||
let expected = std::env::var("WM_ADMIN_TOKEN").unwrap_or_default();
|
||||
if expected.is_empty() {
|
||||
return token.len() > 8;
|
||||
}
|
||||
token == &expected
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user