Skip to content

Commit 304fefc

Browse files
khaliqgantclaude
andcommitted
fix: include relayfile short scopes (fs:read, fs:write) in agent tokens
Relayfile auth.go expects short scopes like "fs:read" while relayauth uses the full format "relayfile:fs:read:/path". Include both in the token so it works with both systems. Also fix admin token scopes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1ec507e commit 304fefc

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

scripts/relay/relay.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ generate_admin_token() {
368368
RELAYAUTH_SUB="relay-admin" \
369369
RELAYAUTH_WORKSPACE="${workspace}" \
370370
RELAYAUTH_AUDIENCE_JSON='["relayauth","relayfile"]' \
371-
RELAYAUTH_SCOPES_JSON='["relayauth:*:manage:*","relayauth:*:read:*","relayfile:*:*:*"]' \
371+
RELAYAUTH_SCOPES_JSON='["relayauth:*:manage:*","relayauth:*:read:*","relayfile:*:*:*","fs:read","fs:write","sync:trigger","ops:read","admin:read"]' \
372372
bash "${DEV_TOKEN_SH}"
373373
}
374374

@@ -611,13 +611,25 @@ cmd_provision() {
611611

612612
# Mint token locally using generate-dev-token.sh (no API call needed —
613613
# signs JWT directly with the shared secret, same key relayfile validates against)
614+
# Include both relayauth-format scopes AND relayfile short scopes (fs:read, fs:write)
615+
# so the token works with both systems.
616+
local merged_scopes
617+
merged_scopes="$(SCOPES="${scopes_json}" node -e '
618+
const scopes = JSON.parse(process.env.SCOPES);
619+
const short = new Set(["fs:read", "fs:write"]);
620+
for (const s of scopes) {
621+
if (s.startsWith("relayfile:fs:read")) short.add("fs:read");
622+
if (s.startsWith("relayfile:fs:write")) short.add("fs:write");
623+
}
624+
console.log(JSON.stringify([...scopes, ...short]));
625+
')"
614626
token="$(
615627
SIGNING_KEY="${secret}" \
616628
RELAYAUTH_SUB="agent_${agent_name}" \
617629
RELAYAUTH_AGENT_NAME="${agent_name}" \
618630
RELAYAUTH_ORG="org_relay" \
619631
RELAYAUTH_WORKSPACE="${workspace}" \
620-
RELAYAUTH_SCOPES_JSON="${scopes_json}" \
632+
RELAYAUTH_SCOPES_JSON="${merged_scopes}" \
621633
RELAYAUTH_AUDIENCE_JSON='["relayauth","relayfile"]' \
622634
bash "${DEV_TOKEN_SH}"
623635
)" || error "failed to generate token for ${agent_name}"

0 commit comments

Comments
 (0)