Skip to content

[2.3] feat: added reference grant mode (#14209)#14238

Merged
davidjumani merged 5 commits into
kgateway-dev:v2.3.xfrom
andy-fong:backport-reference-grant-mode-2.3
Jun 16, 2026
Merged

[2.3] feat: added reference grant mode (#14209)#14238
davidjumani merged 5 commits into
kgateway-dev:v2.3.xfrom
andy-fong:backport-reference-grant-mode-2.3

Conversation

@andy-fong

Copy link
Copy Markdown
Contributor

Description

backport of #14209

Change Type

/kind feature

Changelog

added reference grant mode

Copilot AI review requested due to automatic review settings June 11, 2026 21:05
@andy-fong
andy-fong requested a review from a team as a code owner June 11, 2026 21:05
@gateway-bot gateway-bot added kind/feature Categorizes issue or PR as related to a new feature. release-note labels Jun 11, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ReferenceGrantMode to api/settings.Settings (env: KGW_REFERENCE_GRANT_MODE) with decoding/validation and corresponding unit tests.
  • Wired the configured mode into RefGrantIndex so OFF mode 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]>
@andy-fong andy-fong changed the title feat: added reference grant mode (#14209) [2.3] feat: added reference grant mode (#14209) Jun 11, 2026
Signed-off-by: Andy Fong <[email protected]>
@andy-fong andy-fong added work in progress Indicates that a PR should not merge because it is a work in progress and removed work in progress Indicates that a PR should not merge because it is a work in progress labels Jun 12, 2026
Signed-off-by: Andy Fong <[email protected]>
@davidjumani
davidjumani added this pull request to the merge queue Jun 16, 2026
Merged via the queue into kgateway-dev:v2.3.x with commit baa904c Jun 16, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature Categorizes issue or PR as related to a new feature. release-note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants