From a10548fe732a55c585971095c61956a1dff40207 Mon Sep 17 00:00:00 2001 From: Yang Luo Date: Thu, 26 Oct 2023 23:31:36 +0800 Subject: [PATCH] Fix org admin's enforcer policy APIs --- routers/authz_filter.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/routers/authz_filter.go b/routers/authz_filter.go index 1ad10d99..32994537 100644 --- a/routers/authz_filter.go +++ b/routers/authz_filter.go @@ -66,6 +66,13 @@ func getObject(ctx *context.Context) (string, string) { path := ctx.Request.URL.Path if method == http.MethodGet { + if ctx.Request.URL.Path == "/api/get-policies" && ctx.Input.Query("id") == "/" { + adapterId := ctx.Input.Query("adapterId") + if adapterId != "" { + return util.GetOwnerAndNameFromIdNoCheck(adapterId) + } + } + // query == "?id=built-in/admin" id := ctx.Input.Query("id") if id != "" { @@ -79,8 +86,14 @@ func getObject(ctx *context.Context) (string, string) { return "", "" } else { - body := ctx.Input.RequestBody + if path == "/api/add-policy" || path == "/api/remove-policy" || path == "/api/update-policy" { + id := ctx.Input.Query("id") + if id != "" { + return util.GetOwnerAndNameFromIdNoCheck(id) + } + } + body := ctx.Input.RequestBody if len(body) == 0 { return ctx.Request.Form.Get("owner"), ctx.Request.Form.Get("name") }