Fix org admin's enforcer policy APIs

This commit is contained in:
Yang Luo 2023-10-26 23:31:36 +08:00
parent f6a7888f83
commit a10548fe73

View File

@ -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")
}