Skip to content

Commit

Permalink
feat: improve casnode_session_id code
Browse files Browse the repository at this point in the history
  • Loading branch information
hsluoyz committed Dec 30, 2023
1 parent cd0c2f2 commit 778f0fc
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"github.com/astaxie/beego/plugins/cors"
_ "github.com/astaxie/beego/session/redis"
"github.com/casbin/casnode/casdoor"
"github.com/casbin/casnode/conf"
"github.com/casbin/casnode/object"
"github.com/casbin/casnode/routers"
"github.com/casbin/casnode/service"
Expand Down Expand Up @@ -54,14 +53,16 @@ func main() {
beego.InsertFilter("*", beego.BeforeRouter, routers.Static)
beego.InsertFilter("*", beego.BeforeRouter, routers.AutoSigninFilter)

if conf.GetConfigString("redisEndpoint") == "" {
beego.BConfig.WebConfig.Session.SessionOn = true
beego.BConfig.WebConfig.Session.SessionName = "casnode_session_id"
if beego.AppConfig.String("redisEndpoint") == "" {
beego.BConfig.WebConfig.Session.SessionProvider = "file"
beego.BConfig.WebConfig.Session.SessionProviderConfig = "./tmp"
} else {
beego.BConfig.WebConfig.Session.SessionProvider = "redis"
beego.BConfig.WebConfig.Session.SessionProviderConfig = conf.GetConfigString("redisEndpoint")
beego.BConfig.WebConfig.Session.SessionProviderConfig = beego.AppConfig.String("redisEndpoint")
}
beego.BConfig.WebConfig.Session.SessionGCMaxLifetime = 3600 * 24 * 30
beego.BConfig.WebConfig.Session.SessionGCMaxLifetime = 3600 * 24 * 365

beego.Run()
}

0 comments on commit 778f0fc

Please sign in to comment.