feat(auth): export buildOpaBody for reuse by dependent gateways#55
Merged
Conversation
Extract the OPA request-body construction out of opaAuth into a buildOpaBody(r) helper and export it. Gateways that build on this base image (nginx-s3-gateway) run a combined OPA+credentials auth handler and were rebuilding the OPA input themselves — with a stale header whitelist that diverged from this image's denylist filtering. Exporting the builder lets them send OPA an identical input contract instead. opaAuth behavior is unchanged (pure extraction). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
shimoncohen
added a commit
to MapColonies/nginx-s3-gateway
that referenced
this pull request
Jul 21, 2026
Drop s3_auth.js's own OPA body builder (which used a stale explicit header whitelist) and call the base image's exported base.buildOpaBody, so the gateway sends OPA the same input contract as every other consumer of the shared nginx base (denylist header filtering + size limits). Requires the base export from MapColonies/nginx#55; bump NGINX_BASE_TAG to v2.3.0 accordingly (confirm the exact cut version once #55 releases). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
CptSchnitz
approved these changes
Jul 21, 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.
What
Extracts the OPA request-body construction out of
opaAuthinto an exportedbuildOpaBody(r)helper inauth.js.Why
Gateways that build on top of this base image (e.g.
nginx-s3-gateway, which reuses this image for shared OPA/JWT auth) run a combined OPA→credentials auth handler in a single njs call, so they can't just callopaAuth(which does its own subrequest +r.return). They were rebuilding the OPA input themselves — and had drifted to a stale explicit header whitelist, diverging from this image's current denylist filtering (filterHeaders: blocklist + 2KB size-redaction + prototype-pollution guard).Exporting the builder lets those gateways produce an identical OPA input contract instead of maintaining a divergent copy.
Change
buildOpaBody(r)— returns the{ input: { method, headers: filterHeaders(r), query, domain } }body as a JSON string.opaAuthnow calls it (pure extraction — behavior unchanged).{ opaAuth, jwtPayloadSub, buildOpaBody }.Verification
opaAuth— same body, same flow.