[2.3] feat: added reference grant mode (#14209)#14238
Merged
davidjumani merged 5 commits intoJun 16, 2026
Merged
Conversation
Signed-off-by: Andy Fong <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
Backport of #14209 introducing a configurable ReferenceGrant enforcement mode across the control plane, allowing operators to choose between OFF, PERMISSIVE (default), and STRICT behavior for cross-namespace reference validation.
Changes:
- Added
ReferenceGrantModetoapi/settings.Settings(env:KGW_REFERENCE_GRANT_MODE) with decoding/validation and corresponding unit tests. - Wired the configured mode into
RefGrantIndexsoOFFmode can short-circuit all ReferenceGrant validation at existing call sites. - Added Strict-mode enforcement for TrafficPolicy → GatewayExtension (ExtensionRef) cross-namespace references, plus translator golden tests for each mode.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/pluginsdk/collections/collections.go | Passes settings.ReferenceGrantMode into the ReferenceGrant index during common collection wiring. |
| pkg/krtcollections/policy.go | Stores enforcement mode on RefGrantIndex and bypasses validation when mode is OFF. |
| pkg/krtcollections/secrets_test.go | Updates tests to construct RefGrantIndex with an explicit mode. |
| pkg/krtcollections/policy_test.go | Updates tests to construct RefGrantIndex with an explicit mode. |
| pkg/krtcollections/policy_backendtls_test.go | Updates tests to construct RefGrantIndex with an explicit mode. |
| pkg/krtcollections/grpc_route_test.go | Updates tests to construct RefGrantIndex with an explicit mode. |
| pkg/kgateway/translator/gateway/testutils/outputs/reference-grant-mode/strict-extensionref-with-grant.yaml | Adds golden output for Strict mode with a valid cross-namespace ExtensionRef grant. |
| pkg/kgateway/translator/gateway/testutils/outputs/reference-grant-mode/strict-extensionref-no-grant.yaml | Adds golden output for Strict mode with missing ExtensionRef grant (expected rejection). |
| pkg/kgateway/translator/gateway/testutils/outputs/reference-grant-mode/permissive-extensionref-no-grant.yaml | Adds golden output for Permissive mode where ExtensionRef is not checked. |
| pkg/kgateway/translator/gateway/testutils/outputs/reference-grant-mode/off-backendref-no-grant.yaml | Adds golden output for Off mode where cross-namespace BackendRef is allowed without a grant. |
| pkg/kgateway/translator/gateway/testutils/inputs/reference-grant-mode/strict-extensionref-with-grant.yaml | Adds translator input fixtures for Strict mode with a ReferenceGrant. |
| pkg/kgateway/translator/gateway/testutils/inputs/reference-grant-mode/strict-extensionref-no-grant.yaml | Adds translator input fixtures for Strict mode without a ReferenceGrant. |
| pkg/kgateway/translator/gateway/testutils/inputs/reference-grant-mode/permissive-extensionref-no-grant.yaml | Adds translator input fixtures for Permissive mode (no ExtensionRef grant required). |
| pkg/kgateway/translator/gateway/testutils/inputs/reference-grant-mode/off-backendref-no-grant.yaml | Adds translator input fixtures for Off mode (no grants required). |
| pkg/kgateway/translator/gateway/gateway_translator_test.go | Adds test cases covering Off/Permissive/Strict behaviors via golden fixtures. |
| pkg/kgateway/query/query_test.go | Updates tests to construct RefGrantIndex with an explicit mode. |
| pkg/kgateway/proxy_syncer/gateway_backend_variants_test.go | Updates tests to construct RefGrantIndex with an explicit mode. |
| pkg/kgateway/proxy_syncer/backendtls_synthetic_test.go | Updates tests to construct RefGrantIndex with an explicit mode. |
| pkg/kgateway/extensions2/plugins/trafficpolicy/constructor.go | Enforces ReferenceGrant for cross-namespace ExtensionRef when mode is Strict. |
| devel/reference_grant/reference-grant-mode.md | Adds detailed documentation of modes, coverage, examples, and test regeneration commands. |
| api/settings/settings.go | Introduces ReferenceGrantMode type/constants + env decoding and a new Settings.ReferenceGrantMode field. |
| api/settings/settings_test.go | Adds coverage for KGW_REFERENCE_GRANT_MODE (default, strict, and invalid value). |
Signed-off-by: Andy Fong <[email protected]>
Signed-off-by: Andy Fong <[email protected]>
…grant-mode-2.3 Signed-off-by: Andy Fong <[email protected]>
davidjumani
approved these changes
Jun 15, 2026
Signed-off-by: Andy Fong <[email protected]>
davidjumani
approved these changes
Jun 16, 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.
Description
backport of #14209
Change Type
/kind feature
Changelog