Skip to content

Commit 6d7b0d8

Browse files
Added staging to allowable issuers (#3714)
# Description of Changes This modifies the environment variable that we pass in for requiring SpacetimeAuth to publish so that we can put different issuer values for live and staging. # API and ABI breaking changes This requires a new environment variable or it skips this requirement. # Expected complexity level and risk 1 # Testing I have not tested this change locally. --------- Signed-off-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
1 parent c829c9d commit 6d7b0d8

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

crates/client-api/src/routes/database.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,30 @@ use spacetimedb_schema::auto_migrate::{
4444

4545
use super::subscribe::{handle_websocket, HasWebSocketOptions};
4646

47-
fn require_spacetime_auth_for_creation() -> bool {
48-
env::var("TEMP_REQUIRE_SPACETIME_AUTH").is_ok_and(|v| !v.is_empty())
47+
fn require_spacetime_auth_for_creation() -> Option<String> {
48+
// If the string is a non-empty value, return the string to be used as the required issuer
49+
// TODO(cloutiertyler): This env var replaces TEMP_REQUIRE_SPACETIME_AUTH,
50+
// we should remove that one in the future. We may eventually remove
51+
// the below restriction entirely as well in Maincloud.
52+
match env::var("TEMP_SPACETIMEAUTH_ISSUER_REQUIRED_TO_PUBLISH") {
53+
Ok(v) if !v.is_empty() => Some(v),
54+
_ => None,
55+
}
4956
}
5057

5158
// A hacky function to let us restrict database creation on maincloud.
5259
fn allow_creation(auth: &SpacetimeAuth) -> Result<(), ErrorResponse> {
53-
if !require_spacetime_auth_for_creation() {
60+
let Some(required_issuer) = require_spacetime_auth_for_creation() else {
5461
return Ok(());
55-
}
56-
if auth.claims.issuer.trim_end_matches('/') == "https://auth.spacetimedb.com" {
62+
};
63+
let issuer = auth.claims.issuer.trim_end_matches('/');
64+
if issuer == required_issuer {
5765
Ok(())
5866
} else {
5967
log::trace!(
60-
"Rejecting creation request because auth issuer is {}",
61-
auth.claims.issuer
68+
"Rejecting creation request because auth issuer is {} and required issuer is {}",
69+
auth.claims.issuer,
70+
required_issuer
6271
);
6372
Err((
6473
StatusCode::UNAUTHORIZED,

0 commit comments

Comments
 (0)