feat: token vault support [KOKO-4550] - #181
Merged
Merged
Conversation
LorenzoScebba
marked this pull request as ready for review
September 22, 2026 15:20
LorenzoScebba
force-pushed
the
feat/token-vault-support
branch
from
September 22, 2026 15:21
eab79bb to
0f7bedc
Compare
Contributor
Author
|
/ksai review this pr |
|
✅ KSAI Review: Finished
Run report (federated) · 1 paid run · $1.1482 total
Reviewing cost $1.1478; deciding how to run it cost $0.0004 |
There was a problem hiding this comment.
| Check | Result |
|---|---|
| Scope | Token Vault lowering for MCP servers: convert guards and emit, shared aimap mapping, revert lifting, testdata, e2e test. |
| Mandate | go-code-review (Go files) + default-code-review (docs, YAML, Python, shell) |
| Findings | 1 Medium, 1 Low |
| Findings audit | Audited by kreview:findings-auditor. 2 stand, 0 removed; 1 downgraded to Low with corrected mechanism. |
The change is coherent. Round-trip, golden, and unit tests cover both directions. The two findings are edge and environment issues, not core logic defects.
Additional Risk pass: no leaked secrets; test fixtures use vault references or fake values. No new security surface, no resource leaks, no Critical issues. No additional concerns found.
LorenzoScebba
force-pushed
the
feat/token-vault-support
branch
from
September 23, 2026 13:06
0f7bedc to
0da5737
Compare
GGabriele
approved these changes
Sep 23, 2026
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.
Summary
Adds support for the new top-level
token_vaultproperty on MCP Servers (Konnect specAIGatewayTokenVault), which resolves the upstream credential per request via Kong's Token Vault instead of a static credential. Implemented for both directions:convertlowers it into theai-mcp-proxyplugin'sauthrecord;revertlifts it back.Requires kong-ee PR Kong/kong-ee#21073 (
auth.provider: token_vault+auth.token_vaultonai-mcp-proxy).Mapping
internal/aimap/tokenvault.goso both directions share it (per repo convention).redisblock (KonnectAIGatewayRedisCloudConfiguration) flattens to the Kong redis-ee schema's prefixed keys:keepalive.pool_size→keepalive_pool_size,sentinel.master→sentinel_master,cluster.nodes→cluster_nodes[{ip,port}]vssentinel.nodes[{host,port}],cloud_authentication.type→auth_providerwith provider-prefixed fields (aws_access_key_id,azure_client_id,gcp_service_account_json, …). Field names verified against kong-ee'sredis/v2/schema.lua.encryption_secretsare referenceable ({vault://...}) and pass through verbatim.Hard errors (
failAt, independent of-strict)Mirroring the plugin's own schema/entity checks — emitting a config Kong would reject is never useful:
token_vaulttogether withconfig.upstream.auth(both lower to the same pluginauthrecord, which carries one provider).rediswithoutencryption_secrets.token_vaultpresent but missingdirectory/provider(would otherwise emitauth.token_vault: {}silently).Revert
revertrecognizesauth.provider: token_vaulton an MCP route and lifts it into the top-leveltoken_vaultfield (its position in the AI Gateway schema) instead ofconfig.upstream.auth; only fields present in the deck YAML are set, so the round-trip gate stays byte-identical with zero warnings. Agents are unaffected —ai-a2a-proxydoesn't supporttoken_vault(off/aws_iamonly).Testing
convert/testdata/64_mcp_token_vault,revert/testdata/52_mcp_token_vault(covered byTestRoundTrip).failAtpaths; revert missing-block warn (incl.-strict).e2e-tests/mcp-server/token_vault_gates_tools_and_enrolls/): runs againstkong/kong-ai-gateway-dev:35727837758-070f4458537dcb4fe4d6c7321447cf902d2e07c9with a mock Kong Identity service (KONG_IDENTITY_SERVICE), mock upstream MCP server, and Redis. Verifies the full enrollment lifecycle: schema-valid config at startup → no subject token = 500 → gated caller sees only the virtualtoken_vault_authenticate/token_vault_check_authentication_statustools →authenticatereturns the enrollment URL →check_authentication_statusconfirms enrollment → credential lands in the encrypted Redis L2 cache → enrolled caller sees the real upstream tools, with the upstream receiving the exchanged credential, not the subject token.