internal: set path on cookie for proxy
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> #2305
This commit is contained in:
parent
25a4310bb1
commit
421b003218
|
@ -96,7 +96,7 @@ func NewApplication(p api.ProxyOutpostConfig, c *http.Client, cs *ak.CryptoStore
|
||||||
errorTemplates: templates.GetTemplates(),
|
errorTemplates: templates.GetTemplates(),
|
||||||
ak: ak,
|
ak: ak,
|
||||||
}
|
}
|
||||||
a.sessions = a.getStore(p)
|
a.sessions = a.getStore(p, externalHost)
|
||||||
mux.Use(web.NewLoggingHandler(muxLogger, func(l *log.Entry, r *http.Request) *log.Entry {
|
mux.Use(web.NewLoggingHandler(muxLogger, func(l *log.Entry, r *http.Request) *log.Entry {
|
||||||
s, err := a.sessions.Get(r, constants.SeesionName)
|
s, err := a.sessions.Get(r, constants.SeesionName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -3,6 +3,7 @@ package application
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
@ -12,7 +13,7 @@ import (
|
||||||
"gopkg.in/boj/redistore.v1"
|
"gopkg.in/boj/redistore.v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (a *Application) getStore(p api.ProxyOutpostConfig) sessions.Store {
|
func (a *Application) getStore(p api.ProxyOutpostConfig, externalHost *url.URL) sessions.Store {
|
||||||
var store sessions.Store
|
var store sessions.Store
|
||||||
if config.G.Redis.Host != "" {
|
if config.G.Redis.Host != "" {
|
||||||
rs, err := redistore.NewRediStoreWithDB(10, "tcp", fmt.Sprintf("%s:%d", config.G.Redis.Host, config.G.Redis.Port), config.G.Redis.Password, strconv.Itoa(config.G.Redis.OutpostSessionDB), []byte(*p.CookieSecret))
|
rs, err := redistore.NewRediStoreWithDB(10, "tcp", fmt.Sprintf("%s:%d", config.G.Redis.Host, config.G.Redis.Port), config.G.Redis.Password, strconv.Itoa(config.G.Redis.OutpostSessionDB), []byte(*p.CookieSecret))
|
||||||
|
@ -27,6 +28,7 @@ func (a *Application) getStore(p api.ProxyOutpostConfig) sessions.Store {
|
||||||
} else {
|
} else {
|
||||||
rs.SetMaxAge(0)
|
rs.SetMaxAge(0)
|
||||||
}
|
}
|
||||||
|
rs.Options.Path = externalHost.Path
|
||||||
rs.Options.Domain = *p.CookieDomain
|
rs.Options.Domain = *p.CookieDomain
|
||||||
a.log.Debug("using redis session backend")
|
a.log.Debug("using redis session backend")
|
||||||
store = rs
|
store = rs
|
||||||
|
@ -47,6 +49,7 @@ func (a *Application) getStore(p api.ProxyOutpostConfig) sessions.Store {
|
||||||
} else {
|
} else {
|
||||||
cs.MaxAge(0)
|
cs.MaxAge(0)
|
||||||
}
|
}
|
||||||
|
cs.Options.Path = externalHost.Path
|
||||||
cs.Options.Domain = *p.CookieDomain
|
cs.Options.Domain = *p.CookieDomain
|
||||||
a.log.WithField("dir", dir).Debug("using filesystem session backend")
|
a.log.WithField("dir", dir).Debug("using filesystem session backend")
|
||||||
store = cs
|
store = cs
|
||||||
|
|
Reference in a new issue