feat(guard-identity): add identity guard for unvalidated bearer pass-through#1794
Merged
Conversation
…through Adds a guard that captures the inbound credentials string verbatim and returns it via GuardHandler.credentials(sessionId). Useful when Zilla is chaining a bearer to an upstream that performs its own validation (e.g. proxying GitHub PATs to github-mcp-server, sidecars trusting an upstream IdP, internal gateways behind a verified perimeter). The guard takes no options. Schema rejects any options block. Sessions are shared per (context, identity) and ref-counted; null credentials produce fresh non-shared sessions. - runtime/guard-identity: IdentityGuard, IdentityGuardContext, IdentityGuardHandler, IdentityGuardFactorySpi, plus unit tests (factory, handler) and an integration test driven by engine spec network/application scripts - specs/guard-identity.spec: identity.schema.patch.json adds the "identity" guard type with options: false, additionalProperties: false; SchemaTest validates a minimal positive config
Adds guard-identity to cloud/docker-image/pom.xml and zpm.json.template so the SPI registration is included in ghcr.io/aklivity/zilla images alongside guard-jwt. Without these entries, type: identity would not resolve in deployments using the official image.
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 a new
identityguard that captures the inbound credentials string verbatim and re-emits it viaGuardHandler.credentials(sessionId). No validation, no options.Useful when Zilla is chaining a bearer token to an upstream that performs its own validation:
github-mcp-serverThe current shipped guard (
guard-jwt) validates JWT format on capture, so it cannot carry opaque tokens.identityfills that gap without introducing new SPI surface — it implements the existingGuardHandlercontract (reauthorize/credentials/deauthorize) and integrates with any binding that supportsoptions.authorization.name, includingbinding-mcpandbinding-http.Behavior
reauthorize(credentials)— internscredentialsas the session's identity; returns an auto-generated authorized session idcredentials(sessionId)— returns the stored identity verbatimidentity(sessionId)— same string (these are the same value for this guard)(context, identity)and ref-counted; null credentials produce fresh non-shared sessionsexpiresAt/expiringAt→EXPIRES_NEVER;challenge→false; nopreauthorizeoptionsblock — the guard is configuration-free (type: identityonly)Usage example
The client's
Authorization: Bearer …header is captured atnorth_http_server, propagated through the stream's authorization id, and re-stamped on the outbound request fromapp_clientto the upstream.Test plan
./mvnw checkstyle:check -pl runtime/guard-identity,specs/guard-identity.spec -am— clean./mvnw clean install -pl runtime/guard-identity,specs/guard-identity.spec— passes including ITs and jacoco coverage check (0.82 ratio)IdentityGuardFactoryTest— factory smoke testIdentityGuardTest— handler unit tests covering capture/return/refcount, shared-vs-fresh session semanticsIdentityIT— k3po-driven binding integration test exercising the guard via engine spec network/application scriptsSchemaTest— validates a minimaltype: identityconfig against the patched schemaGenerated by Claude Code