From 79ce91fddee549514c98f002b719fc8cda0e380f Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Wed, 29 Jan 2020 15:47:46 +0800 Subject: Movde dependents on macaron from modules/setting (#10050) Co-authored-by: Lauris BH --- routers/admin/admin.go | 9 ++++++++- routers/routes/routes.go | 22 +++++++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) (limited to 'routers') diff --git a/routers/admin/admin.go b/routers/admin/admin.go index 56e5d321b3..cd425271a3 100644 --- a/routers/admin/admin.go +++ b/routers/admin/admin.go @@ -319,7 +319,14 @@ func Config(ctx *context.Context) { if err := json.Unmarshal([]byte(sessionCfg.ProviderConfig), &realSession); err != nil { log.Error("Unable to unmarshall session config for virtualed provider config: %s\nError: %v", sessionCfg.ProviderConfig, err) } - sessionCfg = realSession + sessionCfg.Provider = realSession.Provider + sessionCfg.ProviderConfig = realSession.ProviderConfig + sessionCfg.CookieName = realSession.CookieName + sessionCfg.CookiePath = realSession.CookiePath + sessionCfg.Gclifetime = realSession.Gclifetime + sessionCfg.Maxlifetime = realSession.Maxlifetime + sessionCfg.Secure = realSession.Secure + sessionCfg.Domain = realSession.Domain } sessionCfg.ProviderConfig = shadowPassword(sessionCfg.Provider, sessionCfg.ProviderConfig) ctx.Data["SessionConfig"] = sessionCfg diff --git a/routers/routes/routes.go b/routers/routes/routes.go index 693f33fddb..a06eb46ad1 100644 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -201,7 +201,16 @@ func NewMacaron() *macaron.Macaron { m.Use(captcha.Captchaer(captcha.Options{ SubURL: setting.AppSubURL, })) - m.Use(session.Sessioner(setting.SessionConfig)) + m.Use(session.Sessioner(session.Options{ + Provider: setting.SessionConfig.Provider, + ProviderConfig: setting.SessionConfig.ProviderConfig, + CookieName: setting.SessionConfig.CookieName, + CookiePath: setting.SessionConfig.CookiePath, + Gclifetime: setting.SessionConfig.Gclifetime, + Maxlifetime: setting.SessionConfig.Maxlifetime, + Secure: setting.SessionConfig.Secure, + Domain: setting.SessionConfig.Domain, + })) m.Use(csrf.Csrfer(csrf.Options{ Secret: setting.SecretKey, Cookie: setting.CSRFCookieName, @@ -963,8 +972,15 @@ func RegisterRoutes(m *macaron.Macaron) { } var handlers []macaron.Handler - if setting.EnableCORS { - handlers = append(handlers, cors.CORS(setting.CORSConfig)) + if setting.CORSConfig.Enabled { + handlers = append(handlers, cors.CORS(cors.Options{ + Scheme: setting.CORSConfig.Scheme, + AllowDomain: setting.CORSConfig.AllowDomain, + AllowSubdomain: setting.CORSConfig.AllowSubdomain, + Methods: setting.CORSConfig.Methods, + MaxAgeSeconds: int(setting.CORSConfig.MaxAge.Seconds()), + AllowCredentials: setting.CORSConfig.AllowCredentials, + })) } handlers = append(handlers, ignSignIn) m.Group("/api", func() { -- cgit v1.2.3