Skip to content

perf: deduplicate JWT authn providers - #9430

Merged
zhaohuabing merged 4 commits into
envoyproxy:mainfrom
Aias00:fix-9103-jwt-authn-dedupe
Jul 10, 2026
Merged

zhaohuabing merged 4 commits into
envoyproxy:mainfrom
Aias00:fix-9103-jwt-authn-dedupe

Conversation

@Aias00

@Aias00 Aias00 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

What this PR does / why we need it

Fixes #9103 by deduplicating identical JWT authentication providers and requirements in listener xDS config. Routes that reuse the same JWT provider now point at a shared jwt_authn requirement, avoiding LDS changes that only add duplicate provider/requirement entries.

Which issue(s) this PR fixes

Fixes #9103

Special notes for your reviewer

The provider and requirement names are now derived from deterministic protobuf serialization hashes of the generated Envoy JWT config. This keeps providers with different settings separate while allowing identical ones to share listener-level config.

Does this PR introduce a user-facing change?

Deduplicated identical JWT authentication providers and requirements in listener xDS config so adding routes that reuse an existing JWT provider no longer changes LDS solely to add duplicate jwt_authn entries.

Testing

  • go test ./internal/xds/translator -run 'TestJWTAuthnDeduplicatesIdenticalRouteProviders|TestTranslateXds' -count=1\n- go test ./internal/xds/translator -count=1\n- go test ./internal/xds/... -count=1\n- bash tools/hack/check-release-notes-filenames.sh\n\nDCO\n\nCommit was created with git commit -s.\n

@Aias00
Aias00 requested a review from a team as a code owner July 7, 2026 13:31
Copilot AI review requested due to automatic review settings July 7, 2026 13:31
@netlify

netlify Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for cerulean-figolla-1f9435 ready!

Name Link
🔨 Latest commit 851dd42
🔍 Latest deploy log https://app.netlify.com/projects/cerulean-figolla-1f9435/deploys/6a4dd3166c94c1000825bd59
😎 Deploy Preview https://deploy-preview-9430--cerulean-figolla-1f9435.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 86ee3dd5dd

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

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 PR addresses #9103 by deduplicating identical Envoy jwt_authn providers and requirements at the listener level, so adding routes that reuse the same JWT configuration avoids LDS changes that only introduce duplicate providers/requirementMap entries. It does so by deriving provider and requirement names from deterministic protobuf-serialization hashes of the generated Envoy JWT config.

Changes:

  • Refactors JWT authn translation to generate provider/requirement names from deterministic proto hashes and share identical entries across routes.
  • Updates per-route jwt_authn PerRouteConfig to reference the shared hashed requirement name.
  • Adds a focused unit test and refreshes translator golden xDS IR outputs and release-note fragment.

Reviewed changes

Copilot reviewed 3 out of 31 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
release-notes/current/performance_improvements/9103-dedupe-jwt-authn-providers.md Adds release-note fragment for JWT authn deduplication behavior.
internal/xds/translator/jwt.go Implements hash-derived naming + dedup logic for JWT providers/requirements and updates per-route requirement references.
internal/xds/translator/jwt_test.go Adds a unit test asserting identical route providers are deduped and routes reference the shared requirement.
internal/xds/translator/testdata/out/xds-ir/securitypolicy-with-oidc-jwt-authz.routes.yaml Updates golden route output to reference hashed JWT requirement name.
internal/xds/translator/testdata/out/xds-ir/securitypolicy-with-oidc-jwt-authz.listeners.yaml Updates golden listener output for hashed provider/requirement keys.
internal/xds/translator/testdata/out/xds-ir/oidc-and-jwt-with-passthrough.routes.yaml Updates golden route output to reference hashed JWT requirement name.
internal/xds/translator/testdata/out/xds-ir/oidc-and-jwt-with-passthrough.listeners.yaml Updates golden listener output for hashed provider/requirement keys.
internal/xds/translator/testdata/out/xds-ir/mixed-tls-jwt-authn.routes.yaml Updates golden route output to reference hashed JWT requirement name.
internal/xds/translator/testdata/out/xds-ir/mixed-tls-jwt-authn.listeners.yaml Updates golden listener output for hashed provider/requirement keys.
internal/xds/translator/testdata/out/xds-ir/jwt-with-backend-tls-retry.routes.yaml Updates golden route output to reference hashed JWT requirement name.
internal/xds/translator/testdata/out/xds-ir/jwt-with-backend-tls-retry.listeners.yaml Updates golden listener output for hashed provider/requirement keys.
internal/xds/translator/testdata/out/xds-ir/jwt-single-route-single-match.routes.yaml Updates golden route output to reference hashed JWT requirement name.
internal/xds/translator/testdata/out/xds-ir/jwt-single-route-single-match.listeners.yaml Updates golden listener output for hashed provider/requirement keys.
internal/xds/translator/testdata/out/xds-ir/jwt-ratelimit.routes.yaml Updates golden route output to reference hashed JWT requirement name.
internal/xds/translator/testdata/out/xds-ir/jwt-ratelimit.listeners.yaml Updates golden listener output for hashed provider/requirement keys.
internal/xds/translator/testdata/out/xds-ir/jwt-optional.routes.yaml Updates golden route output to reference hashed JWT requirement name.
internal/xds/translator/testdata/out/xds-ir/jwt-optional.listeners.yaml Updates golden listener output for hashed provider/requirement keys.
internal/xds/translator/testdata/out/xds-ir/jwt-multi-route-single-provider.routes.yaml Updates golden route output to reference hashed JWT requirement names per route.
internal/xds/translator/testdata/out/xds-ir/jwt-multi-route-single-provider.listeners.yaml Updates golden listener output for hashed provider/requirement keys.
internal/xds/translator/testdata/out/xds-ir/jwt-multi-route-multi-provider.routes.yaml Updates golden route output to reference hashed JWT requirement names per route.
internal/xds/translator/testdata/out/xds-ir/jwt-multi-route-multi-provider.listeners.yaml Updates golden listener output for hashed provider/requirement keys.
internal/xds/translator/testdata/out/xds-ir/jwt-from-multiple-listeners.routes.yaml Updates golden route output to reference hashed JWT requirement names per domain/route.
internal/xds/translator/testdata/out/xds-ir/jwt-from-multiple-listeners.listeners.yaml Updates golden listener output for hashed provider/requirement keys.
internal/xds/translator/testdata/out/xds-ir/jwt-custom-extractor.routes.yaml Updates golden route output to reference hashed JWT requirement name.
internal/xds/translator/testdata/out/xds-ir/jwt-custom-extractor.listeners.yaml Updates golden listener output for hashed provider/requirement keys.
internal/xds/translator/testdata/out/xds-ir/custom-filter-order.routes.yaml Updates golden route output to reference hashed JWT requirement name.
internal/xds/translator/testdata/out/xds-ir/custom-filter-order.listeners.yaml Updates golden listener output for hashed provider/requirement keys.
internal/xds/translator/testdata/out/xds-ir/authorization-jwt-scope.routes.yaml Updates golden route output to reference hashed JWT requirement names for authz scenarios.
internal/xds/translator/testdata/out/xds-ir/authorization-jwt-scope.listeners.yaml Updates golden listener output for hashed provider/requirement keys.
internal/xds/translator/testdata/out/xds-ir/authorization-jwt-claim.routes.yaml Updates golden route output to reference hashed JWT requirement names for claim-based authz.
internal/xds/translator/testdata/out/xds-ir/authorization-jwt-claim.listeners.yaml Updates golden listener output for hashed provider/requirement keys.

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

Comment thread internal/xds/translator/jwt.go Resolved
@Aias00

Aias00 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the review feedback in commit 3d05fae:\n\n- Switched JWT authn provider/requirement hashing to use the full SHA-256 digest instead of a truncated 64-bit prefix.\n- Moved the release note from performance improvements to breaking changes and called out the generated xDS name change impact.\n- Regenerated the affected xDS and egctl translate golden files.\n\nLocal verification:\n- go test ./internal/xds/translator -count=1\n- go test ./internal/cmd/egctl -run TestTranslate -count=1\n- bash tools/hack/check-release-notes-filenames.sh\n\nI also attempted make gen-check, but it failed while reaching the external Helm prometheus-community chart repository with a context deadline exceeded error before completing the repo diff check.

@codecov

codecov Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.39716% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.34%. Comparing base (30d456e) to head (851dd42).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
internal/xds/translator/jwt.go 84.39% 11 Missing and 11 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9430      +/-   ##
==========================================
- Coverage   75.35%   75.34%   -0.01%     
==========================================
  Files         252      252              
  Lines       41475    41533      +58     
==========================================
+ Hits        31254    31295      +41     
- Misses       8108     8118      +10     
- Partials     2113     2120       +7     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Aias00

Aias00 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

/retest

@zhaohuabing zhaohuabing left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Overall, this looks good. I just have a few minor nits about the requirement and provider naming.

Follow the sdsClusterNameFromURL precedent by using a 16-char hash
prefix, drop the redundant jwt/provider and jwt/requirement prefixes,
and include the referenced provider names in the requirement name for
readability. Regenerate affected xDS and egctl translate golden files.

Signed-off-by: liuhy <[email protected]>
@Aias00
Aias00 force-pushed the fix-9103-jwt-authn-dedupe branch from 2bb8462 to 91a2986 Compare July 8, 2026 03:54
Comment thread internal/xds/translator/jwt.go Resolved
Cap generated JWT provider and requirement names at maxJWTNameLength via
boundedJWTName, truncating the human-readable prefix while always keeping
the content hash suffix, so combining many providers cannot produce a name
long enough to fail Envoy xDS validation. Add a test covering the bound.

Signed-off-by: liuhy <[email protected]>
@arkodg arkodg added this to the v1.9.0-rc.1 Release milestone Jul 8, 2026
@zhaohuabing

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 851dd42cdb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@zhaohuabing zhaohuabing left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Thanks!

@zhaohuabing
zhaohuabing requested a review from a team July 8, 2026 06:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Avoid jwt_authn provider/requirementMap duplication in listener config

5 participants