Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

policy API: move type from path to query parameter.

spinningbotf7ef7eb6fe4e
diff --git a/server/acl_casbin_policy_dba.csv b/server/acl_casbin_policy_dba.csv
index 3a763e067d..93bfd0d6d3 100644
--- a/server/acl_casbin_policy_dba.csv
+++ b/server/acl_casbin_policy_dba.csv
@@ -22,7 +22,7 @@ p, DBA, /project/{projectId}/webhook/{webhookId}/test, GET
p, DBA, /environment, POST
p, DBA, /environment, GET
p, DBA, /environment/{id}, PATCH
-p, DBA, /policy/{type}/environment/{environmentId}, GET
+p, DBA, /policy/environment/{environmentId}, GET
p, DBA, /instance, POST
p, DBA, /instance, GET
p, DBA, /instance/{id}, GET
diff --git a/server/acl_casbin_policy_developer.csv b/server/acl_casbin_policy_developer.csv
index fbe243a58c..1191f09ecf 100644
--- a/server/acl_casbin_policy_developer.csv
+++ b/server/acl_casbin_policy_developer.csv
@@ -20,7 +20,7 @@ p, DEVELOPER, /project/{projectId}/webhook/{webhookId}, PATCH
p, DEVELOPER, /project/{projectId}/webhook/{webhookId}, DELETE
p, DEVELOPER, /project/{projectId}/webhook/{webhookId}/test, GET
p, DEVELOPER, /environment, GET
-p, DEVELOPER, /policy/{type}/environment/{environmentId}, GET
+p, DEVELOPER, /policy/environment/{environmentId}, GET
p, DEVELOPER, /instance, GET
p, DEVELOPER, /instance/{id}, GET
p, DEVELOPER, /instance/{id}/user, GET
diff --git a/server/acl_casbin_policy_owner.csv b/server/acl_casbin_policy_owner.csv
index 6e8077e6ac..19acee7efd 100644
--- a/server/acl_casbin_policy_owner.csv
+++ b/server/acl_casbin_policy_owner.csv
@@ -26,8 +26,8 @@ p, OWNER, /project/{projectId}/webhook/{webhookId}/test, GET
p, OWNER, /environment, POST
p, OWNER, /environment, GET
p, OWNER, /environment/{id}, PATCH
-p, OWNER, /policy/{type}/environment/{environmentId}, GET
-p, OWNER, /policy/{type}/environment/{environmentId}, PATCH
+p, OWNER, /policy/environment/{environmentId}, GET
+p, OWNER, /policy/environment/{environmentId}, PATCH
p, OWNER, /instance, POST
p, OWNER, /instance, GET
p, OWNER, /instance/{id}, GET
diff --git a/server/policy.go b/server/policy.go
index f5d4623069..88bf81f34b 100644
--- a/server/policy.go
+++ b/server/policy.go
@@ -12,7 +12,7 @@ import (
)
func (s *Server) registerPolicyRoutes(g *echo.Group) {
- g.PATCH("/policy/:type/environment/:environmentId", func(c echo.Context) error {
+ g.PATCH("/policy/environment/:environmentId", func(c echo.Context) error {
environmentID, err := strconv.Atoi(c.Param("environmentId"))
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("environmentID is not a number: %s", c.Param("id"))).SetInternal(err)
@@ -22,7 +22,7 @@ func (s *Server) registerPolicyRoutes(g *echo.Group) {
if err := jsonapi.UnmarshalPayload(c.Request().Body, policyUpsert); err != nil {
return echo.NewHTTPError(http.StatusBadRequest, "Malformatted set policy request").SetInternal(err)
}
- pType := api.PolicyType(c.Param("type"))
+ pType := api.PolicyType(c.QueryParam("type"))
policyUpsert.EnvironmentId = environmentID
policyUpsert.Type = pType
policyUpsert.UpdaterId = c.Get(GetPrincipalIdContextKey()).(int)
@@ -39,13 +39,13 @@ func (s *Server) registerPolicyRoutes(g *echo.Group) {
return nil
})
- g.GET("/policy/:type/environment/:environmentId", func(c echo.Context) error {
+ g.GET("/policy/environment/:environmentId", func(c echo.Context) error {
environmentID, err := strconv.Atoi(c.Param("environmentId"))
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("environmentID is not a number: %s", c.Param("id"))).SetInternal(err)
}
policyFind := &api.PolicyFind{}
- pType := api.PolicyType(c.Param("type"))
+ pType := api.PolicyType(c.QueryParam("type"))
policyFind.Type = &pType
policyFind.EnvironmentId = &environmentID