Skip to content

Commit 59cc47b

Browse files
NathanFlurryMasterPtato
authored andcommitted
chore(config): make admin_token a secret
1 parent 1aebf8a commit 59cc47b

File tree

3 files changed

+5
-11
lines changed

3 files changed

+5
-11
lines changed
Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
use schemars::JsonSchema;
22
use serde::{Deserialize, Serialize};
33

4+
use crate::secret::Secret;
5+
46
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
57
#[serde(deny_unknown_fields)]
68
pub struct Auth {
7-
pub admin_token: String,
8-
}
9-
10-
impl Default for Auth {
11-
fn default() -> Self {
12-
Auth {
13-
admin_token: "admin".to_string(),
14-
}
15-
}
9+
pub admin_token: Secret<String>,
1610
}

packages/common/config/src/config/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ pub struct Root {
100100
impl Default for Root {
101101
fn default() -> Self {
102102
Root {
103-
auth: Some(Auth::default()),
103+
auth: None,
104104
guard: None,
105105
api_public: None,
106106
api_peer: None,

packages/core/guard/server/src/routing/runner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub async fn route_request(
5757
};
5858

5959
// Validate token
60-
if token != auth.admin_token {
60+
if token != auth.admin_token.read() {
6161
return Err(rivet_api_builder::ApiForbidden.build());
6262
}
6363
}

0 commit comments

Comments
 (0)