[PR #6174] [management] Collect SSH authorized users for bidirectional rules on source peers #29119

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

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/6174
Author: @lixmal
Created: 5/16/2026
Status: 🔄 Open

Base: mainHead: fix-ssh-authorized-users-multi-rule


📝 Commits (3)

  • 10ba4b3 Collect SSH authorized users for bidirectional rules on source peers
  • be57836 Add test for bidirectional SSH rule authorized users on source peers
  • d49bc93 Merge branch 'main' into fix-ssh-authorized-users-multi-rule

📊 Changes

4 files changed (+57 additions, -4 deletions)

View changed files

📝 management/server/types/account.go (+7 -2)
📝 management/server/types/account_components.go (+5 -0)
📝 management/server/types/networkmap_components_correctness_test.go (+38 -0)
📝 shared/management/types/networkmap_components.go (+7 -2)

📄 Description

Describe your changes

Bidirectional SSH policy rules only collected authorized users when the
target peer was in the rule's destinations. For a peer that sits on the
sources side of a bidirectional rule, the rule still permits inbound SSH
from the destinations side, but the peer received an empty authorized
user list and rejected legitimate logins.

  • Treat peer-in-sources as serving the rule when Bidirectional=true, in both Account.getPeerConnectionResources and NetworkMapComponents.getPeerConnectionResources.
  • Apply the same fix to account_components SSH requirement gathering so the upstream allowed-user / group-user lookups still happen for the source-side peer.
  • Add a regression test (TestComponents_SSHAuthorizedUsersBidirectionalSource) that fails on the pre-fix code.

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)

Internal bug fix, no user-visible API or behavior change beyond restoring intended policy semantics.

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
    • Corrected SSH authorization so peers in bidirectional rules can serve as SSH auth endpoints whether on source or destination, ensuring consistent SSH access and proper population of authorized users.
  • Tests
    • Added a test that verifies SSH is enabled and authorized-user mappings are correct for both sides of a bidirectional SSH policy.

Review Change Stack


🔄 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/6174 **Author:** [@lixmal](https://github.com/lixmal) **Created:** 5/16/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix-ssh-authorized-users-multi-rule` --- ### 📝 Commits (3) - [`10ba4b3`](https://github.com/netbirdio/netbird/commit/10ba4b368f8f2dfbadd0076d01e00b3851f0e8d1) Collect SSH authorized users for bidirectional rules on source peers - [`be57836`](https://github.com/netbirdio/netbird/commit/be578368d8ea0b2ed8d2f7113985863b14903a57) Add test for bidirectional SSH rule authorized users on source peers - [`d49bc93`](https://github.com/netbirdio/netbird/commit/d49bc93cb38575cd24f0bad5e3e63a8da2254035) Merge branch 'main' into fix-ssh-authorized-users-multi-rule ### 📊 Changes **4 files changed** (+57 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `management/server/types/account.go` (+7 -2) 📝 `management/server/types/account_components.go` (+5 -0) 📝 `management/server/types/networkmap_components_correctness_test.go` (+38 -0) 📝 `shared/management/types/networkmap_components.go` (+7 -2) </details> ### 📄 Description ## Describe your changes Bidirectional SSH policy rules only collected authorized users when the target peer was in the rule's destinations. For a peer that sits on the sources side of a bidirectional rule, the rule still permits inbound SSH from the destinations side, but the peer received an empty authorized user list and rejected legitimate logins. - Treat peer-in-sources as serving the rule when `Bidirectional=true`, in both `Account.getPeerConnectionResources` and `NetworkMapComponents.getPeerConnectionResources`. - Apply the same fix to `account_components` SSH requirement gathering so the upstream allowed-user / group-user lookups still happen for the source-side peer. - Add a regression test (`TestComponents_SSHAuthorizedUsersBidirectionalSource`) that fails on the pre-fix code. ## Issue ticket number and link ## Stack <!-- branch-stack --> ### Checklist - [x] Is it a bug fix - [ ] Is a typo/documentation fix - [ ] Is a feature enhancement - [ ] It is a refactor - [x] 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) Internal bug fix, no user-visible API or behavior change beyond restoring intended policy semantics. ### 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** * Corrected SSH authorization so peers in bidirectional rules can serve as SSH auth endpoints whether on source or destination, ensuring consistent SSH access and proper population of authorized users. * **Tests** * Added a test that verifies SSH is enabled and authorized-user mappings are correct for both sides of a bidirectional SSH policy. <!-- review_stack_entry_start --> [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/netbirdio/netbird/pull/6174?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- 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 08:07: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#29119