@@ -3,8 +3,10 @@ httpport = 19000 | |||||
runmode = dev | runmode = dev | ||||
SessionOn = true | SessionOn = true | ||||
copyrequestbody = true | copyrequestbody = true | ||||
driverName = mysql | |||||
dataSourceName = root:123@tcp(localhost:3306)/ | dataSourceName = root:123@tcp(localhost:3306)/ | ||||
dbName = casvisor | dbName = casvisor | ||||
redisEndpoint = | |||||
casdoorEndpoint = http://localhost:8000 | casdoorEndpoint = http://localhost:8000 | ||||
clientId = af6b5aa958822fb9dc33 | clientId = af6b5aa958822fb9dc33 | ||||
clientSecret = 8bc3010c1c951c8d876b1f311a901ff8deeb93bc | clientSecret = 8bc3010c1c951c8d876b1f311a901ff8deeb93bc | ||||
@@ -17,6 +17,7 @@ require ( | |||||
github.com/golang-jwt/jwt/v4 v4.1.0 // indirect | github.com/golang-jwt/jwt/v4 v4.1.0 // indirect | ||||
github.com/golang/protobuf v1.4.2 // indirect | github.com/golang/protobuf v1.4.2 // indirect | ||||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db // indirect | github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db // indirect | ||||
github.com/gomodule/redigo v2.0.0+incompatible // indirect | |||||
github.com/hashicorp/golang-lru v0.5.4 // indirect | github.com/hashicorp/golang-lru v0.5.4 // indirect | ||||
github.com/json-iterator/go v1.1.11 // indirect | github.com/json-iterator/go v1.1.11 // indirect | ||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect | github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect | ||||
@@ -178,6 +178,7 @@ github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw | |||||
github.com/golang/snappy v0.0.0-20170215233205-553a64147049/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= | github.com/golang/snappy v0.0.0-20170215233205-553a64147049/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= | ||||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db h1:woRePGFeVFfLKN/pOkfl+p/TAqKOfFu+7KPlMVpok/w= | github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db h1:woRePGFeVFfLKN/pOkfl+p/TAqKOfFu+7KPlMVpok/w= | ||||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= | github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= | ||||
github.com/gomodule/redigo v2.0.0+incompatible h1:K/R+8tc58AaqLkqG2Ol3Qk+DR/TlNuhuh457pBFPtt0= | |||||
github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4= | github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4= | ||||
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= | github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= | ||||
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= | github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= | ||||
@@ -3,6 +3,7 @@ package main | |||||
import ( | import ( | ||||
"github.com/astaxie/beego" | "github.com/astaxie/beego" | ||||
"github.com/astaxie/beego/plugins/cors" | "github.com/astaxie/beego/plugins/cors" | ||||
_ "github.com/astaxie/beego/session/redis" | |||||
"github.com/casbin/casvisor/object" | "github.com/casbin/casvisor/object" | ||||
"github.com/casbin/casvisor/routers" | "github.com/casbin/casvisor/routers" | ||||
) | ) | ||||
@@ -24,8 +25,13 @@ func main() { | |||||
beego.InsertFilter("/", beego.BeforeRouter, routers.TransparentStatic) // must has this for default page | beego.InsertFilter("/", beego.BeforeRouter, routers.TransparentStatic) // must has this for default page | ||||
beego.InsertFilter("/*", beego.BeforeRouter, routers.TransparentStatic) | beego.InsertFilter("/*", beego.BeforeRouter, routers.TransparentStatic) | ||||
beego.BConfig.WebConfig.Session.SessionProvider = "file" | |||||
beego.BConfig.WebConfig.Session.SessionProviderConfig = "./tmp" | |||||
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 = beego.AppConfig.String("redisEndpoint") | |||||
} | |||||
beego.BConfig.WebConfig.Session.SessionGCMaxLifetime = 3600 * 24 * 365 | beego.BConfig.WebConfig.Session.SessionGCMaxLifetime = 3600 * 24 * 365 | ||||
beego.Run() | beego.Run() | ||||
@@ -21,7 +21,7 @@ func InitConfig() { | |||||
} | } | ||||
func InitAdapter() { | func InitAdapter() { | ||||
adapter = NewAdapter("mysql", beego.AppConfig.String("dataSourceName")) | |||||
adapter = NewAdapter(beego.AppConfig.String("driverName"), beego.AppConfig.String("dataSourceName")) | |||||
} | } | ||||
// Adapter represents the MySQL adapter for policy storage. | // Adapter represents the MySQL adapter for policy storage. | ||||
@@ -10,7 +10,7 @@ export let CasdoorSdk; | |||||
export function initServerUrl() { | export function initServerUrl() { | ||||
const hostname = window.location.hostname; | const hostname = window.location.hostname; | ||||
if (hostname === 'localhost') { | if (hostname === 'localhost') { | ||||
ServerUrl = `http://${hostname}:17000`; | |||||
ServerUrl = `http://${hostname}:19000`; | |||||
} | } | ||||
} | } | ||||