Skip to content

api: add packAsBytes to SecurityPolicy extAuth bodyToExtAuth - #10213

Open
jamesglennan wants to merge 3 commits into
envoyproxy:mainfrom
jamesglennan:feat/extauth-pack-as-bytes
Open

jamesglennan wants to merge 3 commits into
envoyproxy:mainfrom
jamesglennan:feat/extauth-pack-as-bytes

Conversation

@jamesglennan

Copy link
Copy Markdown

What this PR does / why we need it:

Adds packAsBytes to SecurityPolicy extAuth.bodyToExtAuth. It maps to Envoy's ext_authz BufferSettings.pack_as_bytes.

By default, Envoy sends the buffered request body to a gRPC external authorization service as a UTF-8 string in AttributeContext.HttpRequest.body. Binary or non-UTF-8 bodies (protobuf, file uploads, compressed payloads) can't be inspected reliably that way. With packAsBytes: true, the body is sent as raw bytes in raw_body instead.

extAuth:
  bodyToExtAuth:
    maxRequestBytes: 32768
    packAsBytes: true
  grpc:
    backendRefs:
      - name: grpc-ext-auth
        port: 9002

Envoy says pack_as_bytes only affects grpc_service and has no effect with http_service. A CEL rule on ExtAuth therefore rejects packAsBytes: true unless grpc is set. An explicit false is still allowed with http.

Making maxRequestBytes optional (separate commit, open for discussion)

maxRequestBytes is currently required whenever bodyToExtAuth is set. That made sense when it was the only field, but it means someone who only wants raw bytes still has to choose a buffer size. The last commit makes it optional and defaults it to 32768 bytes (32KiB), which matches Envoy Gateway's default per-connection listener buffer limit. The translator always fills in the default, so Envoy never receives a 0, which it would reject.

It's a standalone commit with its own tests. If maintainers prefer to keep maxRequestBytes required, reverting that commit leaves the rest of the PR working. I raised the question on #10193.

Changes

  • API: BodyToExtAuth.PackAsBytes *bool, plus a CEL rule on ExtAuth that only allows packAsBytes: true with gRPC.
  • IR, gateway-api translator and xDS translator: the value is passed through to BufferSettings.PackAsBytes.
  • Tests:
    • CEL cases for gRPC and HTTP with packAsBytes set to true, false or unset, and with maxRequestBytes set, unset, or bodyToExtAuth: {}.
    • gateway-api translator testdata for packAsBytes true, unset, and with the maxRequestBytes default.
    • xDS translator testdata for gRPC with packAsBytes true and unset.
  • Docs: a "Sending the Request Body" subsection in the ext-auth task, plus regenerated API reference docs.
  • Generated CRDs, helm test outputs, deepcopy, and a release note.

Which issue(s) this PR fixes:

Fixes #10193


PR Checklist

  • Authorship & ownership: Coding agents / AI assistants are welcome, but I have reviewed every change, understand how and why it works, can explain and maintain it, and take full responsibility for this PR. I have not submitted generated output I do not understand.
  • DCO: All commits are signed off (git commit -s). See DCO: Sign your work.
  • API agreed first: If this PR contains API changes (changes under /api), the API was discussed and agreed before the implementation. The API change can be in a separate PR, or in the same PR, but the API must be agreed before implementation. N/A if this PR does not contain API changes. (Proposed in Support packAsBytes in SecurityPolicy extAuth.bodyToExtAuth #10193 and awaiting triage. This PR stays a draft until the API is agreed.)
  • Required checks pass: make generate gen-check, make lint, and the unit-test/coverage build pass. (Flaky e2e failures are not considered breakages, but gen-check, lint, and coverage MUST pass.)
  • Tests added/updated: New/changed code is covered by appropriate tests. N/A if this PR does not contain code changes.
  • Docs: User-facing changes update the docs, either in this PR or a follow-up PR. N/A if this PR does not contain user-facing changes.
  • Release notes: For any non-trivial change, added a release-note fragment under release-notes/current/<section>/<pr-number>-<slug>.md (see release-notes/current/README.md for sections and naming). N/A if this PR does not contain non-trivial changes.
  • Generated files committed: Ran make gen-check and committed the result if API/helm charts/modules changed.
  • Scope & compatibility: The PR is reasonably scoped (no unrelated changes) and preserves backward compatibility, or any breaking change is called out above and documented in release-notes/current/breaking_changes/.
  • Codex review: Requested a Codex review and addressed all of its comments.
  • Copilot review: Requested a Copilot review and addressed all of its comments.

@netlify

netlify Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

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

Name Link
🔨 Latest commit 5c91d9d
🔍 Latest deploy log https://app.netlify.com/projects/cerulean-figolla-1f9435/deploys/6acd9cc990beaf8392a9db5c
😎 Deploy Preview https://deploy-preview-10213--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.

@codecov

codecov Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.54%. Comparing base (c3d52d8) to head (71b2288).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #10213   +/-   ##
=======================================
  Coverage   81.54%   81.54%           
=======================================
  Files         266      266           
  Lines       41568    41570    +2     
=======================================
+ Hits        33896    33900    +4     
+ Misses       7671     7669    -2     
  Partials        1        1           

☔ 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.

@arkodg

arkodg commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T02:55:22.210978Z 5c91d9d New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 20b059360c

ℹ️ 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".

@jamesglennan
jamesglennan marked this pull request as ready for review October 8, 2026 21:44
@jamesglennan
jamesglennan requested a review from a team as a code owner October 8, 2026 21:44
Comment thread api/v1alpha1/ext_auth_types.go
@jamesglennan
jamesglennan force-pushed the feat/extauth-pack-as-bytes branch from 978ee81 to 71b2288 Compare October 9, 2026 03:32

@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: 71b22881b0

ℹ️ 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".

Comment thread api/v1alpha1/ext_auth_types.go
Signed-off-by: James Glennan <james.glennan@cyberark.com>
Signed-off-by: James Glennan <james.glennan@cyberark.com>
Default maxRequestBytes to 32768 bytes (32KiB), matching the default
per-connection buffer limit, so options such as packAsBytes can be set
without also specifying a buffer size.

This is a standalone commit so it can be reverted if maintainers prefer
to keep maxRequestBytes required.

Signed-off-by: James Glennan <james.glennan@cyberark.com>
@jamesglennan
jamesglennan force-pushed the feat/extauth-pack-as-bytes branch from 71b2288 to 5c91d9d Compare October 13, 2026 02:51
@jamesglennan

Copy link
Copy Markdown
Author

@zirain Not sure what the protocol is to get this merged, do I need to get API change approval?

This branch has not been deployed

No deployments
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.

Support packAsBytes in SecurityPolicy extAuth.bodyToExtAuth

3 participants