diff --git a/object/resource.go b/object/resource.go index 5cd64913..603e5277 100644 --- a/object/resource.go +++ b/object/resource.go @@ -16,6 +16,7 @@ package object import ( "fmt" + "strings" "github.com/casdoor/casdoor/util" "github.com/xorm-io/core" @@ -76,6 +77,10 @@ func GetPaginationResources(owner, user string, offset, limit int, field, value, } func getResource(owner string, name string) (*Resource, error) { + if !strings.HasPrefix(name, "/") { + name = "/" + name + } + resource := Resource{Owner: owner, Name: name} existed, err := adapter.Engine.Get(&resource) if err != nil { diff --git a/routers/authz_filter.go b/routers/authz_filter.go index dc245f1f..2cadc6b4 100644 --- a/routers/authz_filter.go +++ b/routers/authz_filter.go @@ -156,7 +156,7 @@ func AuthzFilter(ctx *context.Context) { urlPath := getUrlPath(ctx.Request.URL.Path) objOwner, objName := "", "" - if urlPath != "/api/get-app-login" { + if urlPath != "/api/get-app-login" && urlPath != "/api/get-resource" { objOwner, objName = getObject(ctx) }