Skip to content

Commit fc4287a

Browse files
authored
[subrepls] Allow authentication (#51)
We want to be able to have subrepls, which share the same auth realm as the main Repl. This adds that.
1 parent d0a569b commit fc4287a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/auth.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,8 @@ fn validate_token(token: &str, replid: &str, pubkeys: &HashMap<String, Vec<u8>>)
461461
Some(crate::api::repl_token::Metadata::Id(id)) => id.id.clone(),
462462
_ => bail!("token does not contain a replid: {:?}", &repl_token),
463463
};
464-
if token_replid != replid {
464+
let pruned_replid = replid.split_once(":").map(|(replid, _)| replid.to_string());
465+
if token_replid != replid && Some(&token_replid) != pruned_replid.as_ref() {
465466
bail!(
466467
"token not issued for replid {:?}: {:?}",
467468
&token_replid,
@@ -1056,6 +1057,8 @@ mod tests {
10561057
.expect("Failed to generate PASETO");
10571058

10581059
validate_token(&token, &replid.to_string(), &pubkeys).expect("Failed to validate token");
1060+
validate_token(&token, &format!("{replid}:01").to_string(), &pubkeys)
1061+
.expect("Failed to validate token");
10591062
validate_token(
10601063
&String::from("this is not a token"),
10611064
&replid.to_string(),

0 commit comments

Comments
 (0)