Skip to content

Commit 6a72b5d

Browse files
authored
fml (#37)
1 parent d49a283 commit 6a72b5d

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

internal/oauth/resource_indicators.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,12 @@ func ValidateAudienceForService(requestPath string, tokenAudience []string, issu
206206
}
207207

208208
// Workaround: accept base issuer as audience if enabled
209-
if acceptIssuerAudience && slices.Contains(tokenAudience, issuer) {
210-
return nil
209+
// Check both with and without trailing slash since clients may normalize differently
210+
if acceptIssuerAudience {
211+
normalized := strings.TrimSuffix(issuer, "/")
212+
if slices.Contains(tokenAudience, normalized) || slices.Contains(tokenAudience, normalized+"/") {
213+
return nil
214+
}
211215
}
212216

213217
return fmt.Errorf("token audience %v does not include required resource %s for service %s",

internal/oauth/resource_indicators_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,13 @@ func TestValidateAudienceForService(t *testing.T) {
359359
wantErr: true,
360360
errContains: "does not include required resource",
361361
},
362+
{
363+
name: "issuer audience with trailing slash accepted",
364+
requestPath: "/postgres/sse",
365+
tokenAudience: []string{"https://mcp.company.com/"},
366+
acceptIssuerAudience: true,
367+
wantErr: false,
368+
},
362369
}
363370

364371
for _, tt := range tests {

0 commit comments

Comments
 (0)