[PR #6887] [management, proxy] Add OR mode for reverse proxy access restrictions #27409

Open
opened 2026-08-05 07:08:40 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/6887
Author: @lixmal
Created: 7/24/2026
Status: 🔄 Open

Base: mainHead: reverse-proxy-allow-match-or


📝 Commits (6)

  • 40cdfda Add allow_match any/all mode to reverse proxy access restrictions
  • 2243d1c Read reverse proxy restrictions in Postgres pgx path
  • 172914e Preserve allow_match in restriction conversions when it is the only field set
  • 82d3123 Merge branch 'main' into reverse-proxy-allow-match-or
  • 2beb90a Resolve the country once per check in allow_match any mode
  • f05f3fc Merge branch 'main' into reverse-proxy-allow-match-or

📊 Changes

10 files changed (+918 additions, -385 deletions)

View changed files

📝 management/internals/modules/reverseproxy/service/service.go (+30 -2)
📝 management/internals/modules/reverseproxy/service/service_test.go (+59 -0)
📝 management/server/store/sql_store_service_test.go (+39 -0)
📝 proxy/internal/restrict/restrict.go (+93 -0)
📝 proxy/internal/restrict/restrict_test.go (+260 -0)
📝 proxy/server.go (+1 -0)
📝 shared/management/http/api/openapi.yml (+12 -0)
📝 shared/management/http/api/types.gen.go (+24 -0)
📝 shared/management/proto/proxy_service.pb.go (+396 -383)
📝 shared/management/proto/proxy_service.proto (+4 -0)

📄 Description

Describe your changes

Access restrictions on reverse-proxy services currently combine the different allowlists with AND, so a connection must match every configured allowlist. That makes rules like "allow country X OR CIDR Y" impossible to express, and adding a CIDR allowlist silently denies country-allowed clients (and vice versa). This adds an allow_match option to control how the allowlists combine.

  • Add allow_match to access restrictions: all (default, AND) requires matching every allowlist, any (OR) requires matching at least one, e.g. an allowed country or an allowed CIDR
  • Keep blocklists as a hard deny regardless of the mode, and fall back to all for an empty or unknown value so behavior never loosens unexpectedly
  • Preserve existing behavior for services with no allow_match set (treated as all)

https://github.com/netbirdio/netbird/issues/5862

Stack

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)
  • This change does not modify the public API, gRPC protocols, functionality behavior, CLI / service flags, or introduce a new feature — OR I have discussed it with the NetBird team beforehand (link the issue / Slack thread in the description). See CONTRIBUTING.md.

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.

Documentation

Select exactly one:

  • I added/updated documentation for this change
  • Documentation is not needed for this change (explain why)

Docs PR URL (required if "docs added" is checked)

Paste the PR link from https://github.com/netbirdio/docs here:

https://github.com/netbirdio/docs/pull/884

Summary by CodeRabbit

  • New Features
    • Added allow_match to access restrictions to control allowlist combination: all (AND) or any (OR), with all as default.
  • Bug Fixes
    • Improved validation and consistent legacy/empty handling for allow_match.
    • Fixed service restriction loading from storage so configured restrictions persist correctly.
  • Tests
    • Added coverage for allow/deny semantics, API/proto round-trips, geo/crowd control behavior, validation failures, and storage persistence.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbirdio/netbird/pull/6887 **Author:** [@lixmal](https://github.com/lixmal) **Created:** 7/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `reverse-proxy-allow-match-or` --- ### 📝 Commits (6) - [`40cdfda`](https://github.com/netbirdio/netbird/commit/40cdfda878cf8808b3c6d957191b01532e1ba957) Add allow_match any/all mode to reverse proxy access restrictions - [`2243d1c`](https://github.com/netbirdio/netbird/commit/2243d1c3bbcefcfe210061aa8cdf8acff0faeb20) Read reverse proxy restrictions in Postgres pgx path - [`172914e`](https://github.com/netbirdio/netbird/commit/172914e5ee7280980f5728a04ed4bf265207e169) Preserve allow_match in restriction conversions when it is the only field set - [`82d3123`](https://github.com/netbirdio/netbird/commit/82d31231e4573f884cc55449d606285ac04e2ff3) Merge branch 'main' into reverse-proxy-allow-match-or - [`2beb90a`](https://github.com/netbirdio/netbird/commit/2beb90aeebb19d4cc6c820a6d21fe22694bef054) Resolve the country once per check in allow_match any mode - [`f05f3fc`](https://github.com/netbirdio/netbird/commit/f05f3fc005fd55f67948ba7e6adac47f662709b0) Merge branch 'main' into reverse-proxy-allow-match-or ### 📊 Changes **10 files changed** (+918 additions, -385 deletions) <details> <summary>View changed files</summary> 📝 `management/internals/modules/reverseproxy/service/service.go` (+30 -2) 📝 `management/internals/modules/reverseproxy/service/service_test.go` (+59 -0) 📝 `management/server/store/sql_store_service_test.go` (+39 -0) 📝 `proxy/internal/restrict/restrict.go` (+93 -0) 📝 `proxy/internal/restrict/restrict_test.go` (+260 -0) 📝 `proxy/server.go` (+1 -0) 📝 `shared/management/http/api/openapi.yml` (+12 -0) 📝 `shared/management/http/api/types.gen.go` (+24 -0) 📝 `shared/management/proto/proxy_service.pb.go` (+396 -383) 📝 `shared/management/proto/proxy_service.proto` (+4 -0) </details> ### 📄 Description ## Describe your changes Access restrictions on reverse-proxy services currently combine the different allowlists with AND, so a connection must match every configured allowlist. That makes rules like "allow country X OR CIDR Y" impossible to express, and adding a CIDR allowlist silently denies country-allowed clients (and vice versa). This adds an `allow_match` option to control how the allowlists combine. - Add `allow_match` to access restrictions: `all` (default, AND) requires matching every allowlist, `any` (OR) requires matching at least one, e.g. an allowed country or an allowed CIDR - Keep blocklists as a hard deny regardless of the mode, and fall back to `all` for an empty or unknown value so behavior never loosens unexpectedly - Preserve existing behavior for services with no `allow_match` set (treated as `all`) ## Issue ticket number and link https://github.com/netbirdio/netbird/issues/5862 ## Stack <!-- branch-stack --> ### Checklist - [ ] Is it a bug fix - [ ] Is a typo/documentation fix - [x] Is a feature enhancement - [ ] It is a refactor - [x] Created tests that fail without the change (if possible) - [x] This change does **not** modify the public API, gRPC protocols, functionality behavior, CLI / service flags, or introduce a new feature — **OR** I have discussed it with the NetBird team beforehand (link the issue / Slack thread in the description). See [CONTRIBUTING.md](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTING.md#discuss-changes-with-the-netbird-team-first). > By submitting this pull request, you confirm that you have read and agree to the terms of the [Contributor License Agreement](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT.md). ## Documentation Select exactly one: - [x] I added/updated documentation for this change - [ ] Documentation is **not needed** for this change (explain why) ### Docs PR URL (required if "docs added" is checked) Paste the PR link from https://github.com/netbirdio/docs here: https://github.com/netbirdio/docs/pull/884 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added `allow_match` to access restrictions to control allowlist combination: **all** (AND) or **any** (OR), with **all** as default. * **Bug Fixes** * Improved validation and consistent legacy/empty handling for `allow_match`. * Fixed service restriction loading from storage so configured restrictions persist correctly. * **Tests** * Added coverage for allow/deny semantics, API/proto round-trips, geo/crowd control behavior, validation failures, and storage persistence. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2026-08-05 07:08:40 -04:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#27409