mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 10:45:47 +08:00
Add logger.
This commit is contained in:
parent
8a4311c85c
commit
a24665714a
8
main.go
8
main.go
@ -16,6 +16,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
|
"github.com/astaxie/beego/logs"
|
||||||
"github.com/astaxie/beego/plugins/cors"
|
"github.com/astaxie/beego/plugins/cors"
|
||||||
"github.com/casdoor/casdoor/authz"
|
"github.com/casdoor/casdoor/authz"
|
||||||
"github.com/casdoor/casdoor/controllers"
|
"github.com/casdoor/casdoor/controllers"
|
||||||
@ -54,5 +55,12 @@ func main() {
|
|||||||
beego.BConfig.WebConfig.Session.SessionGCMaxLifetime = 3600 * 24 * 365
|
beego.BConfig.WebConfig.Session.SessionGCMaxLifetime = 3600 * 24 * 365
|
||||||
//beego.BConfig.WebConfig.Session.SessionCookieSameSite = http.SameSiteNoneMode
|
//beego.BConfig.WebConfig.Session.SessionCookieSameSite = http.SameSiteNoneMode
|
||||||
|
|
||||||
|
err := logs.SetLogger("file", `{"filename":"logs/casdoor.log","maxdays":99999}`)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
logs.SetLevel(logs.LevelInformational)
|
||||||
|
logs.SetLogFuncCall(false)
|
||||||
|
|
||||||
beego.Run()
|
beego.Run()
|
||||||
}
|
}
|
||||||
|
@ -102,8 +102,14 @@ func AuthzFilter(ctx *context.Context) {
|
|||||||
|
|
||||||
isAllowed := authz.IsAllowed(subOwner, subName, method, urlPath, objOwner, objName)
|
isAllowed := authz.IsAllowed(subOwner, subName, method, urlPath, objOwner, objName)
|
||||||
|
|
||||||
fmt.Printf("subOwner = %s, subName = %s, method = %s, urlPath = %s, obj.Owner = %s, obj.Name = %s, isAllowed = %v\n",
|
result := "deny"
|
||||||
subOwner, subName, method, urlPath, objOwner, objName, isAllowed)
|
if isAllowed {
|
||||||
|
result = "allow"
|
||||||
|
}
|
||||||
|
logLine := fmt.Sprintf("subOwner = %s, subName = %s, method = %s, urlPath = %s, obj.Owner = %s, obj.Name = %s, result = %s",
|
||||||
|
subOwner, subName, method, urlPath, objOwner, objName, result)
|
||||||
|
fmt.Println(logLine)
|
||||||
|
util.LogInfo(ctx, logLine)
|
||||||
if !isAllowed {
|
if !isAllowed {
|
||||||
denyRequest(ctx)
|
denyRequest(ctx)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user