|
@@ -96,11 +96,11 @@ func CreateDefaultAclNetworkPolicies(netID models.NetworkID) {
|
|
InsertAcl(defaultUserAcl)
|
|
InsertAcl(defaultUserAcl)
|
|
}
|
|
}
|
|
|
|
|
|
- if !IsAclExists(fmt.Sprintf("%s.%s", netID, "all-remote-access-gws")) {
|
|
|
|
|
|
+ if !IsAclExists(fmt.Sprintf("%s.%s", netID, "all-gateways")) {
|
|
defaultUserAcl := models.Acl{
|
|
defaultUserAcl := models.Acl{
|
|
- ID: fmt.Sprintf("%s.%s", netID, "all-remote-access-gws"),
|
|
|
|
|
|
+ ID: fmt.Sprintf("%s.%s", netID, "all-gateways"),
|
|
Default: true,
|
|
Default: true,
|
|
- Name: "All Remote Access Gateways",
|
|
|
|
|
|
+ Name: "All Gateways",
|
|
NetworkID: netID,
|
|
NetworkID: netID,
|
|
Proto: models.ALL,
|
|
Proto: models.ALL,
|
|
ServiceType: models.Any,
|
|
ServiceType: models.Any,
|
|
@@ -109,7 +109,7 @@ func CreateDefaultAclNetworkPolicies(netID models.NetworkID) {
|
|
Src: []models.AclPolicyTag{
|
|
Src: []models.AclPolicyTag{
|
|
{
|
|
{
|
|
ID: models.NodeTagID,
|
|
ID: models.NodeTagID,
|
|
- Value: fmt.Sprintf("%s.%s", netID, models.RemoteAccessTagName),
|
|
|
|
|
|
+ Value: fmt.Sprintf("%s.%s", netID, models.GwTagName),
|
|
},
|
|
},
|
|
},
|
|
},
|
|
Dst: []models.AclPolicyTag{
|
|
Dst: []models.AclPolicyTag{
|
|
@@ -590,10 +590,23 @@ func convAclTagToValueMap(acltags []models.AclPolicyTag) map[string]struct{} {
|
|
|
|
|
|
// IsUserAllowedToCommunicate - check if user is allowed to communicate with peer
|
|
// IsUserAllowedToCommunicate - check if user is allowed to communicate with peer
|
|
func IsUserAllowedToCommunicate(userName string, peer models.Node) (bool, []models.Acl) {
|
|
func IsUserAllowedToCommunicate(userName string, peer models.Node) (bool, []models.Acl) {
|
|
|
|
+ var peerId string
|
|
if peer.IsStatic {
|
|
if peer.IsStatic {
|
|
|
|
+ peerId = peer.StaticNode.ClientID
|
|
peer = peer.StaticNode.ConvertToStaticNode()
|
|
peer = peer.StaticNode.ConvertToStaticNode()
|
|
|
|
+ } else {
|
|
|
|
+ peerId = peer.ID.String()
|
|
}
|
|
}
|
|
- peer.Tags[models.TagID(peer.ID.String())] = struct{}{}
|
|
|
|
|
|
+
|
|
|
|
+ var peerTags map[models.TagID]struct{}
|
|
|
|
+ if peer.Mutex != nil {
|
|
|
|
+ peer.Mutex.Lock()
|
|
|
|
+ peerTags = maps.Clone(peer.Tags)
|
|
|
|
+ peer.Mutex.Unlock()
|
|
|
|
+ } else {
|
|
|
|
+ peerTags = peer.Tags
|
|
|
|
+ }
|
|
|
|
+ peerTags[models.TagID(peerId)] = struct{}{}
|
|
acl, _ := GetDefaultPolicy(models.NetworkID(peer.Network), models.UserPolicy)
|
|
acl, _ := GetDefaultPolicy(models.NetworkID(peer.Network), models.UserPolicy)
|
|
if acl.Enabled {
|
|
if acl.Enabled {
|
|
return true, []models.Acl{acl}
|
|
return true, []models.Acl{acl}
|
|
@@ -617,7 +630,7 @@ func IsUserAllowedToCommunicate(userName string, peer models.Node) (bool, []mode
|
|
allowedPolicies = append(allowedPolicies, policy)
|
|
allowedPolicies = append(allowedPolicies, policy)
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
- for tagID := range peer.Tags {
|
|
|
|
|
|
+ for tagID := range peerTags {
|
|
if _, ok := dstMap[tagID.String()]; ok {
|
|
if _, ok := dstMap[tagID.String()]; ok {
|
|
allowedPolicies = append(allowedPolicies, policy)
|
|
allowedPolicies = append(allowedPolicies, policy)
|
|
break
|
|
break
|