Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NET-1911: ACL policy improvements, add colors to tags #3342

Open
wants to merge 34 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
021023d
allow single devices in the acl policies
abhishek9686 Jan 17, 2025
8de1f4f
single node acl group
abhishek9686 Jan 20, 2025
0e3e916
Merge branch 'develop' of https://github.com/gravitl/netmaker into NE…
abhishek9686 Jan 26, 2025
1db150c
fix node id acl validation
abhishek9686 Jan 27, 2025
9ba818f
add node acl rules to fw update
abhishek9686 Jan 27, 2025
2c720d0
fix user acl device policy
abhishek9686 Jan 29, 2025
d2d5658
Merge branch 'develop' of https://github.com/gravitl/netmaker into NE…
abhishek9686 Jan 31, 2025
9a40717
fix single device policies
abhishek9686 Feb 1, 2025
46d79ee
support static nodes in standalone device policies
abhishek9686 Feb 3, 2025
a9c14c4
Merge branch 'develop' of https://github.com/gravitl/netmaker into NE…
abhishek9686 Feb 4, 2025
3bdb7fb
fix src policy check
abhishek9686 Feb 5, 2025
9cf2ad4
add color coding to tags
abhishek9686 Feb 6, 2025
61bf479
upsert on color update
abhishek9686 Feb 7, 2025
fabc9f2
optimise firewall rules
abhishek9686 Feb 8, 2025
28af115
fix static node id policy
abhishek9686 Feb 9, 2025
41fa0b1
resolve merge conflicts
abhishek9686 Feb 14, 2025
ed1f48a
remove node id from acls when deleted
abhishek9686 Feb 14, 2025
9812b5c
remove deleted users from acl policy
abhishek9686 Feb 14, 2025
d22a6a3
resolve merge conflicts
abhishek9686 Feb 17, 2025
8536f0e
extclients from policies
abhishek9686 Feb 18, 2025
98606bc
fix static node ingress rules
abhishek9686 Feb 18, 2025
9590f9e
resolve merge conflicts
abhishek9686 Feb 19, 2025
e50da80
Merge branch 'develop' of https://github.com/gravitl/netmaker into NE…
abhishek9686 Feb 24, 2025
5963c58
Merge branch 'develop' of https://github.com/gravitl/netmaker into NE…
abhishek9686 Feb 24, 2025
90b76b4
Merge branch 'develop' into NET-1911
abhishek9686 Feb 28, 2025
6f9afdc
Merge branch 'NET-1911' of https://github.com/gravitl/netmaker into N…
abhishek9686 Feb 28, 2025
b45a926
optimise static node rules, fix traffic flows for static nodes
abhishek9686 Mar 5, 2025
e22519c
fix acls rules on node
abhishek9686 Mar 5, 2025
984db44
fix extclient comms to gws
abhishek9686 Mar 5, 2025
9a1c1c2
fix extclient comms to gws
abhishek9686 Mar 5, 2025
6e1b16a
fix ext-ext comms
abhishek9686 Mar 5, 2025
8f370a7
fix ipv6 addr rules on gw node
abhishek9686 Mar 6, 2025
bb25739
resolve merge conflicts
abhishek9686 Mar 6, 2025
0e4f163
fix merge conflicts
abhishek9686 Mar 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 48 additions & 8 deletions controllers/acls.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ func aclPolicyTypes(w http.ResponseWriter, r *http.Request) {
SrcGroupTypes: []models.AclGroupType{
models.UserAclID,
models.UserGroupAclID,
models.DeviceAclID,
models.NodeTagID,
models.NodeID,
},
DstGroupTypes: []models.AclGroupType{
models.DeviceAclID,
models.NodeTagID,
models.NodeID,
// models.NetmakerIPAclID,
// models.NetmakerSubNetRangeAClID,
},
Expand Down Expand Up @@ -117,6 +119,13 @@ func aclPolicyTypes(w http.ResponseWriter, r *http.Request) {
},
PortRange: "",
},
{
Name: models.SSH,
AllowedProtocols: []models.Protocol{
models.TCP,
},
PortRange: "22",
},
{
Name: models.Custom,
AllowedProtocols: []models.Protocol{
Expand All @@ -134,18 +143,49 @@ func aclPolicyTypes(w http.ResponseWriter, r *http.Request) {
func aclDebug(w http.ResponseWriter, r *http.Request) {
nodeID, _ := url.QueryUnescape(r.URL.Query().Get("node"))
peerID, _ := url.QueryUnescape(r.URL.Query().Get("peer"))
peerIsStatic, _ := url.QueryUnescape(r.URL.Query().Get("peer_is_static"))
node, err := logic.GetNodeByID(nodeID)
if err != nil {
logic.ReturnErrorResponse(w, r, logic.FormatError(err, "badrequest"))
return
}
peer, err := logic.GetNodeByID(peerID)
if err != nil {
logic.ReturnErrorResponse(w, r, logic.FormatError(err, "badrequest"))
return
var peer models.Node
if peerIsStatic == "true" {
extclient, err := logic.GetExtClient(peerID, node.Network)
if err != nil {
logic.ReturnErrorResponse(w, r, logic.FormatError(err, "badrequest"))
return
}
peer = extclient.ConvertToStaticNode()

} else {
peer, err = logic.GetNodeByID(peerID)
if err != nil {
logic.ReturnErrorResponse(w, r, logic.FormatError(err, "badrequest"))
return
}
}
type resp struct {
IsNodeAllowed bool
IsPeerAllowed bool
Policies []models.Acl
IngressRules []models.FwRule
}

allowed, ps := logic.IsNodeAllowedToCommunicateV1(node, peer, true)
isallowed := logic.IsPeerAllowed(node, peer, true)
re := resp{
IsNodeAllowed: allowed,
IsPeerAllowed: isallowed,
Policies: ps,
}
if peerIsStatic == "true" {
ingress, err := logic.GetNodeByID(peer.StaticNode.IngressGatewayID)
if err == nil {
re.IngressRules = logic.GetFwRulesOnIngressGateway(ingress)
}
}
allowed, _ := logic.IsNodeAllowedToCommunicate(node, peer, true)
logic.ReturnSuccessResponseWithJson(w, r, allowed, "fetched all acls in the network ")
logic.ReturnSuccessResponseWithJson(w, r, re, "fetched all acls in the network ")
}

// @Summary List Acls in a network
Expand Down
9 changes: 9 additions & 0 deletions controllers/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ func createTag(w http.ResponseWriter, r *http.Request) {
TagName: req.TagName,
Network: req.Network,
CreatedBy: user.UserName,
ColorCode: req.ColorCode,
CreatedAt: time.Now(),
}
_, err = logic.GetTag(tag.ID)
Expand Down Expand Up @@ -182,6 +183,14 @@ func updateTag(w http.ResponseWriter, r *http.Request) {
// delete old Tag entry
logic.DeleteTag(updateTag.ID, false)
}
if updateTag.ColorCode != "" && updateTag.ColorCode != tag.ColorCode {
tag.ColorCode = updateTag.ColorCode
err = logic.UpsertTag(tag)
if err != nil {
logic.ReturnErrorResponse(w, r, logic.FormatError(err, "badrequest"))
return
}
}
go func() {
logic.UpdateTag(updateTag, newID)
if updateTag.NewName != "" {
Expand Down
Loading