[PR #4853] [MERGED] [client] Add excluded port range handling for PKCE flow #21425

Closed
opened 2026-08-05 05:08:29 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/4853
Author: @mlsmaycon
Created: 11/24/2025
Status: Merged
Merged: 11/26/2025
Merged by: @lixmal

Base: mainHead: handle-reserved-windows-ports


📝 Commits (3)

  • 3cd9bc1 [client] Add excluded port range handling for PKCE flow
  • 0975883 correct test name
  • 00516fb [client] Switch to netsh for excluded port range retrieval in PKCE flow on Windows

📊 Changes

5 files changed (+398 additions, -5 deletions)

View changed files

📝 client/internal/auth/pkce_flow.go (+41 -5)
client/internal/auth/pkce_flow_other.go (+8 -0)
📝 client/internal/auth/pkce_flow_test.go (+147 -0)
client/internal/auth/pkce_flow_windows.go (+86 -0)
client/internal/auth/pkce_flow_windows_test.go (+116 -0)

📄 Description

Describe your changes

Introduce support for handling system-excluded port ranges in PKCE flow. Update port validation to skip excluded and in-use ports, including integration of Windows-specific logic to retrieve excluded ranges from the registry. Add tests for various usage scenarios across platforms.

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)

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/__

Summary by CodeRabbit

  • Bug Fixes

    • Detect and avoid system-reserved port ranges when selecting redirect URLs on Windows.
    • Port availability checks now respect OS-specific excluded port ranges for more consistent redirect selection.
  • Tests

    • Added tests covering port exclusion parsing and redirect URL selection behavior across scenarios.

✏️ Tip: You can customize this high-level summary in your review settings.


🔄 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/4853 **Author:** [@mlsmaycon](https://github.com/mlsmaycon) **Created:** 11/24/2025 **Status:** ✅ Merged **Merged:** 11/26/2025 **Merged by:** [@lixmal](https://github.com/lixmal) **Base:** `main` ← **Head:** `handle-reserved-windows-ports` --- ### 📝 Commits (3) - [`3cd9bc1`](https://github.com/netbirdio/netbird/commit/3cd9bc1790b528d325fdb890c9a0c4dc592c302f) [client] Add excluded port range handling for PKCE flow - [`0975883`](https://github.com/netbirdio/netbird/commit/0975883e1b9c0cfa2991bd3f72b45799ef815431) correct test name - [`00516fb`](https://github.com/netbirdio/netbird/commit/00516fb56a78fc212f2ac9113362f44d43852764) [client] Switch to netsh for excluded port range retrieval in PKCE flow on Windows ### 📊 Changes **5 files changed** (+398 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `client/internal/auth/pkce_flow.go` (+41 -5) ➕ `client/internal/auth/pkce_flow_other.go` (+8 -0) 📝 `client/internal/auth/pkce_flow_test.go` (+147 -0) ➕ `client/internal/auth/pkce_flow_windows.go` (+86 -0) ➕ `client/internal/auth/pkce_flow_windows_test.go` (+116 -0) </details> ### 📄 Description ## Describe your changes Introduce support for handling system-excluded port ranges in PKCE flow. Update port validation to skip excluded and in-use ports, including integration of Windows-specific logic to retrieve excluded ranges from the registry. Add tests for various usage scenarios across platforms. ## Issue ticket number and link ## Stack <!-- branch-stack --> ### Checklist - [ ] Is it a bug fix - [ ] Is a typo/documentation fix - [x] Is a feature enhancement - [ ] It is a refactor - [ ] Created tests that fail without the change (if possible) > 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: - [ ] I added/updated documentation for this change - [x] 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/__ <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Detect and avoid system-reserved port ranges when selecting redirect URLs on Windows. * Port availability checks now respect OS-specific excluded port ranges for more consistent redirect selection. * **Tests** * Added tests covering port exclusion parsing and redirect URL selection behavior across scenarios. <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- 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 05:08:29 -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#21425