mirror of
https://github.com/Dasemu/Synapse.git
synced 2026-11-26 23:36:20 +00:00
fix(server): refuse an MCP token equal to a sync token
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4195374c23
commit
053d1f9d90
2 files changed
+23
No files matched your search
@@ -93,6 +93,11 @@ impl Config {
|
|||||||
{
|
{
|
||||||
return Err("SYNAPSE_MCP_TOKEN has no token".into());
|
return Err("SYNAPSE_MCP_TOKEN has no token".into());
|
||||||
}
|
}
|
||||||
|
if let Some(m) = &self.mcp
|
||||||
|
&& m.tokens.iter().any(|t| self.auth_tokens.contains(t))
|
||||||
|
{
|
||||||
|
return Err("SYNAPSE_MCP_TOKEN must differ from the sync tokens".into());
|
||||||
|
}
|
||||||
let mcp_tokens = self.mcp.iter().flat_map(|m| m.tokens.iter());
|
let mcp_tokens = self.mcp.iter().flat_map(|m| m.tokens.iter());
|
||||||
for t in self
|
for t in self
|
||||||
.auth_tokens
|
.auth_tokens
|
||||||
|
|||||||
@@ -185,3 +185,21 @@ async fn writes_go_through_the_op_log() {
|
|||||||
assert!(ops.to_string().contains("rejects aliasing"), "{ops}");
|
assert!(ops.to_string().contains("rejects aliasing"), "{ops}");
|
||||||
srv.shutdown();
|
srv.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn mcp_token_must_differ_from_sync_tokens() {
|
||||||
|
let cfg = Config {
|
||||||
|
bind: "127.0.0.1:0".parse().unwrap(),
|
||||||
|
data_dir: "/tmp/unused".into(),
|
||||||
|
auth_tokens: vec![SYNC_TOKEN.into()],
|
||||||
|
update_token: None,
|
||||||
|
update_script: "/nonexistent".into(),
|
||||||
|
max_clock_skew: Duration::from_secs(600),
|
||||||
|
mcp: Some(McpConfig {
|
||||||
|
tokens: vec![SYNC_TOKEN.into()],
|
||||||
|
allow_write: false,
|
||||||
|
allowed_hosts: Vec::new(),
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
assert!(cfg.validate().is_err());
|
||||||
|
}
|
||||||
Reference in new issue
Block a user