Skip to content

[2.2] feat: added reference grant mode (#14209)#14239

Merged
davidjumani merged 2 commits into
kgateway-dev:v2.2.xfrom
andy-fong:af-reference-grant-mode-2.2
Jun 15, 2026
Merged

[2.2] feat: added reference grant mode (#14209)#14239
davidjumani merged 2 commits into
kgateway-dev:v2.2.xfrom
andy-fong:af-reference-grant-mode-2.2

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 23:10
@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

This backport introduces a configurable ReferenceGrant enforcement mode across kgateway, allowing operators to choose between backward-compatible behavior and stricter cross-namespace reference validation (including TrafficPolicy -> GatewayExtension).

Changes:

  • Adds ReferenceGrantMode (OFF, PERMISSIVE default, STRICT) to api/settings with env var parsing for KGW_REFERENCE_GRANT_MODE.
  • Wires the mode into RefGrantIndex and short-circuits all ReferenceGrant checks when mode is OFF.
  • Enforces ReferenceGrant for cross-namespace ExtensionRef resolution in Strict mode and adds translator golden tests + documentation covering all modes.

Reviewed changes

Copilot reviewed 19 out of 19 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 NewRefGrantIndex during common collection setup.
pkg/krtcollections/policy.go Extends RefGrantIndex to store mode and bypass checks when mode is OFF.
pkg/krtcollections/secrets_test.go Updates test construction of RefGrantIndex with explicit mode.
pkg/krtcollections/policy_test.go Updates test construction of RefGrantIndex with explicit mode.
pkg/krtcollections/grpc_route_test.go Updates test construction of RefGrantIndex with explicit mode.
pkg/kgateway/query/query_test.go Updates test construction of RefGrantIndex with explicit mode.
pkg/kgateway/extensions2/plugins/trafficpolicy/constructor.go Adds Strict-mode ReferenceGrant enforcement for cross-namespace ExtensionRef to GatewayExtension.
api/settings/settings.go Introduces ReferenceGrantMode type, decoding, and Settings.ReferenceGrantMode envconfig field.
api/settings/settings_test.go Adds coverage for default, strict env var parsing, and invalid mode error case.
devel/reference_grant/reference-grant-mode.md Adds operator/developer documentation for the three modes, their coverage, and test guidance.
pkg/kgateway/translator/gateway/gateway_translator_test.go Adds golden test cases validating behavior for OFF / PERMISSIVE / STRICT modes.
pkg/kgateway/translator/gateway/testutils/inputs/reference-grant-mode/strict-extensionref-with-grant.yaml Adds strict-mode input fixture (with ReferenceGrant) for golden testing.
pkg/kgateway/translator/gateway/testutils/inputs/reference-grant-mode/strict-extensionref-no-grant.yaml Adds strict-mode input fixture (missing grant) for golden testing.
pkg/kgateway/translator/gateway/testutils/inputs/reference-grant-mode/permissive-extensionref-no-grant.yaml Adds permissive-mode input fixture (no grant required for ExtensionRef) for golden testing.
pkg/kgateway/translator/gateway/testutils/inputs/reference-grant-mode/off-backendref-no-grant.yaml Adds off-mode input fixture (no grants required) for golden testing.
pkg/kgateway/translator/gateway/testutils/outputs/reference-grant-mode/strict-extensionref-with-grant.yaml Adds strict-mode expected output (grant present).
pkg/kgateway/translator/gateway/testutils/outputs/reference-grant-mode/strict-extensionref-no-grant.yaml Adds strict-mode expected output (grant missing, policy rejected).
pkg/kgateway/translator/gateway/testutils/outputs/reference-grant-mode/permissive-extensionref-no-grant.yaml Adds permissive-mode expected output (ExtensionRef allowed without grant).
pkg/kgateway/translator/gateway/testutils/outputs/reference-grant-mode/off-backendref-no-grant.yaml Adds off-mode expected output (cross-namespace BackendRef allowed).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@andy-fong andy-fong changed the title feat: added reference grant mode (#14209) [2.2] 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
@davidjumani
davidjumani added this pull request to the merge queue Jun 15, 2026
Merged via the queue into kgateway-dev:v2.2.x with commit 851b73b Jun 15, 2026
38 of 39 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