mirror of
https://github.com/jhillyerd/inbucket.git
synced 2026-05-14 17:43:49 +00:00
Session cookie key is now configurable
- Added [web] cookie.auth.key to configuration - Inbucket generates a random key if none is configured - Added [default] default.domain to be reference by SMTP and POP3 configs - Updated default/sample config files
This commit is contained in:
@@ -43,14 +43,21 @@ func headerMatch(req *http.Request, name string, value string) bool {
|
||||
func NewContext(req *http.Request) (*Context, error) {
|
||||
vars := mux.Vars(req)
|
||||
sess, err := sessionStore.Get(req, "inbucket")
|
||||
if err != nil {
|
||||
if sess == nil {
|
||||
// No session, must fail
|
||||
return nil, err
|
||||
} else {
|
||||
// The session cookie was probably signed by an old key, ignore it
|
||||
// gorilla created an empty session for us
|
||||
err = nil
|
||||
}
|
||||
}
|
||||
ctx := &Context{
|
||||
Vars: vars,
|
||||
Session: sess,
|
||||
DataStore: DataStore,
|
||||
IsJSON: headerMatch(req, "Accept", "application/json"),
|
||||
}
|
||||
if err != nil {
|
||||
return ctx, err
|
||||
}
|
||||
return ctx, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user