From f14d9169365cb22dc2965897bb7185c04846b13e Mon Sep 17 00:00:00 2001 From: abhishek9686 Date: Thu, 12 Dec 2024 02:32:36 +0400 Subject: [PATCH] for any service set defaults --- controllers/acls.go | 4 ++++ logic/acls.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/controllers/acls.go b/controllers/acls.go index ffaa66636..2871aef55 100644 --- a/controllers/acls.go +++ b/controllers/acls.go @@ -207,6 +207,10 @@ func createAcl(w http.ResponseWriter, r *http.Request) { acl.CreatedBy = user.UserName acl.CreatedAt = time.Now().UTC() acl.Default = false + if acl.ServiceType == models.Any { + acl.Port = []string{} + acl.Proto = models.ALL + } // validate create acl policy if !logic.IsAclPolicyValid(acl) { logic.ReturnErrorResponse(w, r, logic.FormatError(errors.New("invalid policy"), "badrequest")) diff --git a/logic/acls.go b/logic/acls.go index bd9f40257..ff9a99e16 100644 --- a/logic/acls.go +++ b/logic/acls.go @@ -325,6 +325,10 @@ func UpdateAcl(newAcl, acl models.Acl) error { acl.Proto = newAcl.Proto acl.ServiceType = newAcl.ServiceType } + if newAcl.ServiceType == models.Any { + acl.Port = []string{} + acl.Proto = models.ALL + } acl.Enabled = newAcl.Enabled d, err := json.Marshal(acl) if err != nil {