fix: let a restricted caller re-save a token's mcp:session marker

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
hugocasa
2026-10-26 17:27:49 +01:00
co-authored by Claude Opus 5.5
parent 50feb9ddba
commit 708964bbc2
+8 -1
View File
@@ -591,7 +591,9 @@ pub fn ensure_scopes_within_caller(
for requested in requested_restrictions {
if requested.starts_with("mcp:") {
if !caller_mcp.contains(requested.as_str()) {
// `mcp:session` (windmill_mcp's SESSION_SCOPE) grants nothing: it only picks
// the toolset an `mcp:all` token gets, and `mcp:all` is matched here itself.
if requested != "mcp:session" && !caller_mcp.contains(requested.as_str()) {
return Err(Error::PermissionDenied(format!(
"A scope-restricted token cannot grant MCP scope '{requested}' unless the \
caller holds the same scope verbatim"
@@ -1964,6 +1966,11 @@ mod tests {
opt_scopes(Some(vec!["mcp:scripts:*"])).as_deref()
)
.is_err());
assert!(ensure_scopes_within_caller(
&mcp_all,
opt_scopes(Some(vec!["mcp:all", "mcp:session"])).as_deref()
)
.is_ok());
}
#[test]