mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-27 06:49:07 +01:00
Collect SSH authorized users for bidirectional rules on source peers
This commit is contained in:
@@ -1039,7 +1039,12 @@ func (a *Account) GetPeerConnectionResources(ctx context.Context, peer *nbpeer.P
|
|||||||
generateResources(rule, sourcePeers, FirewallRuleDirectionIN)
|
generateResources(rule, sourcePeers, FirewallRuleDirectionIN)
|
||||||
}
|
}
|
||||||
|
|
||||||
if peerInDestinations && rule.Protocol == PolicyRuleProtocolNetbirdSSH {
|
// Auth is collected when this peer serves the rule. For bidirectional
|
||||||
|
// rules the peer-in-sources side also serves inbound traffic, so it
|
||||||
|
// must be treated as a destination too.
|
||||||
|
peerServesAuth := peerInDestinations || (rule.Bidirectional && peerInSources)
|
||||||
|
|
||||||
|
if peerServesAuth && rule.Protocol == PolicyRuleProtocolNetbirdSSH {
|
||||||
sshEnabled = true
|
sshEnabled = true
|
||||||
switch {
|
switch {
|
||||||
case len(rule.AuthorizedGroups) > 0:
|
case len(rule.AuthorizedGroups) > 0:
|
||||||
@@ -1071,7 +1076,7 @@ func (a *Account) GetPeerConnectionResources(ctx context.Context, peer *nbpeer.P
|
|||||||
default:
|
default:
|
||||||
authorizedUsers[auth.Wildcard] = a.getAllowedUserIDs()
|
authorizedUsers[auth.Wildcard] = a.getAllowedUserIDs()
|
||||||
}
|
}
|
||||||
} else if peerInDestinations && policyRuleImpliesLegacySSH(rule) && peer.SSHEnabled {
|
} else if peerServesAuth && policyRuleImpliesLegacySSH(rule) && peer.SSHEnabled {
|
||||||
sshEnabled = true
|
sshEnabled = true
|
||||||
authorizedUsers[auth.Wildcard] = a.getAllowedUserIDs()
|
authorizedUsers[auth.Wildcard] = a.getAllowedUserIDs()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -342,7 +342,12 @@ func (a *Account) getPeersGroupsPoliciesRoutes(
|
|||||||
for _, srcGroupID := range rule.Sources {
|
for _, srcGroupID := range rule.Sources {
|
||||||
relevantGroupIDs[srcGroupID] = a.GetGroup(srcGroupID)
|
relevantGroupIDs[srcGroupID] = a.GetGroup(srcGroupID)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SSH auth requirements are gathered whenever this peer serves
|
||||||
|
// the rule. For bidirectional rules the peer-in-sources side
|
||||||
|
// also serves inbound traffic and must be treated as a destination.
|
||||||
|
if peerInDestinations || (rule.Bidirectional && peerInSources) {
|
||||||
if rule.Protocol == PolicyRuleProtocolNetbirdSSH {
|
if rule.Protocol == PolicyRuleProtocolNetbirdSSH {
|
||||||
switch {
|
switch {
|
||||||
case len(rule.AuthorizedGroups) > 0:
|
case len(rule.AuthorizedGroups) > 0:
|
||||||
|
|||||||
@@ -230,7 +230,12 @@ func (c *NetworkMapComponents) getPeerConnectionResources(targetPeerID string) (
|
|||||||
generateResources(rule, sourcePeers, FirewallRuleDirectionIN)
|
generateResources(rule, sourcePeers, FirewallRuleDirectionIN)
|
||||||
}
|
}
|
||||||
|
|
||||||
if peerInDestinations && rule.Protocol == PolicyRuleProtocolNetbirdSSH {
|
// Auth is collected when this peer serves the rule. For bidirectional
|
||||||
|
// rules the peer-in-sources side also serves inbound traffic, so it
|
||||||
|
// must be treated as a destination too.
|
||||||
|
peerServesAuth := peerInDestinations || (rule.Bidirectional && peerInSources)
|
||||||
|
|
||||||
|
if peerServesAuth && rule.Protocol == PolicyRuleProtocolNetbirdSSH {
|
||||||
sshEnabled = true
|
sshEnabled = true
|
||||||
switch {
|
switch {
|
||||||
case len(rule.AuthorizedGroups) > 0:
|
case len(rule.AuthorizedGroups) > 0:
|
||||||
@@ -261,7 +266,7 @@ func (c *NetworkMapComponents) getPeerConnectionResources(targetPeerID string) (
|
|||||||
default:
|
default:
|
||||||
authorizedUsers[auth.Wildcard] = c.getAllowedUserIDs()
|
authorizedUsers[auth.Wildcard] = c.getAllowedUserIDs()
|
||||||
}
|
}
|
||||||
} else if peerInDestinations && policyRuleImpliesLegacySSH(rule) && targetPeer.SSHEnabled {
|
} else if peerServesAuth && policyRuleImpliesLegacySSH(rule) && targetPeer.SSHEnabled {
|
||||||
sshEnabled = true
|
sshEnabled = true
|
||||||
authorizedUsers[auth.Wildcard] = c.getAllowedUserIDs()
|
authorizedUsers[auth.Wildcard] = c.getAllowedUserIDs()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user