fix(operator): scope API keys per-model via per-route authorization (#116)#117
Open
dcmcand wants to merge 5 commits into
Open
fix(operator): scope API keys per-model via per-route authorization (#116)#117dcmcand wants to merge 5 commits into
dcmcand wants to merge 5 commits into
Conversation
Add apiKeyAuth.forwardClientIDHeader + sanitize and a deny-by-default authorization block listing each model's own client IDs to the external SecurityPolicy. A key valid on the shared listener now gets 403 against a model it was not minted for. Covers LLMModel and PassthroughModel. Closes #116
Watch managed api-keys Secrets and enqueue the owning model so minting or revoking a key promptly updates the per-route authorization allow-list.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this fixes
Closes #116. Today any valid API key works for every model on the shared external gateway listener (
llm.<baseDomain>). Envoy Gateway pools theapiKeyAuthcredentials from every per-model SecurityPolicy on that listener into one set, so a key minted for a cheap model authenticates against an expensive or restricted one just by changing themodelfield. Group checks at mint time still hold, but there was no request-time per-model enforcement on the API-key path.Approach
The isolation belongs in authorization, not authentication. Each model's external SecurityPolicy now gets:
apiKeyAuth.forwardClientIDHeader: x-llm-client-idandsanitize: trueauthorizationblock:defaultAction: Denyplus one Allow rule listing only the client IDs present in that model's own api-keys SecretA foreign key still passes the pooled authentication, but it forwards a client ID that is not in the target route's allow-list, so authorization returns 403. The single shared listener and single TLS certificate are unchanged.
The operator reads each model's api-keys Secret to build the allow-list and watches that Secret (label-filtered, no owner reference) so minting or revoking a key re-renders the policy within about a minute. Both served (
LLMModel) and passthrough (PassthroughModel) models are covered through the shared builder.Note on the Envoy Gateway version
The
auth.goTODO claimedforwardClientIDHeader/sanitizeneed EG v1.7+. That is not correct: both fields exist as of EG v1.5.7 / v1.6.0, andAuthorization.Principal.Headers(exact header matching) is available too. The dev stack is already on EG v1.6.7 (via #115), and AI Gateway v0.5 already forces an EG v1.6.x floor, so this needs no version bump. The stale TODO is removed.Behavior
With a key minted only into model A's Secret:
Blocked by #115
This is stacked on #115 (which aligns the dev stack to EG v1.6.7). The PR is based on
feat/local-dev-passthrough-and-ui-devmodeso the diff shows only this change; it should merge after #115. GitHub will retarget it tomainonce #115 lands.Test plan
Automated (passing):
buildExternalSecurityPolicy/ passthrough builder renderforwardClientIDHeader,sanitize: true, andauthorization: defaultAction: DenyLLMModelandPassthroughModelpaths coveredDeferred (needs the EG v1.6.7 dev stack from #115, so not yet run): the end-to-end curl matrix on a live cluster (the 200/403/401 cases above, plus revoke and fresh-mint timing). This is tracked and will be run once #115 merges and the stack is available.
Docs in
docs/design.mdare updated to describe the per-model authorization and to correct a stale claim that per-model hostnames enforced access control.