Skip to content

feat: changed opa headers mechanism from whitelist to blacklist#47

Merged
shimoncohen merged 5 commits into
masterfrom
blacklist-headers
Jun 23, 2026
Merged

feat: changed opa headers mechanism from whitelist to blacklist#47
shimoncohen merged 5 commits into
masterfrom
blacklist-headers

Conversation

@CptSchnitz

@CptSchnitz CptSchnitz commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Description:
This PR refactors the NGINX njs script to transition our OPA header filtering from an allowlist (whitelist) to a denylist (blocklist).

Key benefits of this change:

  • Enabled zero-friction policy updates: I removed the need for NGINX deployments just to add new headers. Future custom headers for new policies will now automatically flow through to OPA.
  • Improved observability and debugging: Header typos are no longer silently dropped at the edge. Invalid or misspelled headers now reach OPA and appear in the decision logs, making troubleshooting much faster.
  • Maintained performance & reduced log bloat: I implemented a highly optimized, O(1) module-level denylist to explicitly strip out heavy, irrelevant payloads (Cookie, raw Authorization, legacy tracing, and cache/network noise). This ensures we keep request latency low and OPA payload sizes lean.

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 updates the NGINX njs OPA authorization request payload construction by switching from an explicit header allowlist to a general “pass-through except denylist” mechanism, so OPA receives more request header context by default.

Changes:

  • Added a DENYLIST of request headers to exclude from OPA input.
  • Introduced filterHeaders(r) to forward all non-denylisted r.headersIn entries to OPA.
  • Replaced the previous hardcoded header allowlist with headers: filterHeaders(r) in the OPA input payload.

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

Comment thread docker-image/nginx-config/auth.js
Comment thread docker-image/nginx-config/auth.js Outdated
CptSchnitz and others added 3 commits June 21, 2026 10:52
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Comment thread docker-image/nginx-config/auth.js
Comment thread docker-image/nginx-config/auth.js
@shimoncohen shimoncohen merged commit 69de12f into master Jun 23, 2026
1 check passed
@shimoncohen shimoncohen deleted the blacklist-headers branch June 23, 2026 08:06
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.

4 participants