Skip to content

Commit 1a42e9b

Browse files
jrhynessclaude
andcommitted
fix: use bound subscription for X-MaaS-Subscription header
Use apiKeyValidation.subscription (bound) instead of subscription-info.name (selected) for the X-MaaS-Subscription header. For K8s tokens, the expression returns empty string so no header is injected. This aligns with actual usage: API keys for inference (needs header for Istio Telemetry), K8s tokens for /v1/models catalog browsing (no subscription tracking needed). Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent fe9ffad commit 1a42e9b

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

maas-controller/pkg/controller/maas/maasauthpolicy_controller.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -456,12 +456,11 @@ allow {
456456
rule["response"] = map[string]interface{}{
457457
"success": map[string]interface{}{
458458
"headers": map[string]interface{}{
459-
// X-MaaS-Subscription required for Istio Telemetry metrics (per-subscription latency)
460-
// Other identity headers (Username, Group, Key-Id) intentionally omitted to prevent
461-
// disclosure in model workload logs. This is server-controlled (not client-provided).
459+
// Subscription bound to API key (only for API keys)
460+
// For K8s tokens, this header is not injected (empty string)
462461
"X-MaaS-Subscription": map[string]interface{}{
463462
"plain": map[string]interface{}{
464-
"expression": `has(auth.metadata["subscription-info"].name) ? auth.metadata["subscription-info"].name : ""`,
463+
"expression": `(has(auth.metadata) && has(auth.metadata.apiKeyValidation)) ? auth.metadata.apiKeyValidation.subscription : ""`,
465464
},
466465
"metrics": false,
467466
"priority": int64(0),

0 commit comments

Comments
 (0)