Skip to content
This repository was archived by the owner on Nov 7, 2025. It is now read-only.

Commit 8e16393

Browse files
committed
Make secure cookies working
1 parent 911f24a commit 8e16393

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

quesma/quesma/ui/console_routes.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"encoding/json"
99
"errors"
1010
"github.com/gorilla/mux"
11+
"github.com/gorilla/securecookie"
1112
"github.com/gorilla/sessions"
1213
"github.com/markbates/goth"
1314
"github.com/markbates/goth/gothic"
@@ -29,6 +30,10 @@ var uiFs embed.FS
2930

3031
const quesmaSessionName = "quesma-session"
3132

33+
func init() {
34+
gothic.Store = sessions.NewCookieStore(securecookie.GenerateRandomKey(32))
35+
}
36+
3237
func authCallbackHandler(w http.ResponseWriter, r *http.Request) {
3338
user, err := gothic.CompleteUserAuth(w, r)
3439
if err != nil {
@@ -247,7 +252,9 @@ func (qmc *QuesmaManagementConsole) initPprof(router *mux.Router) {
247252
router.HandleFunc("/debug/pprof/trace", pprof.Trace)
248253
}
249254

250-
var store = sessions.NewCookieStore([]byte("test"))
255+
var authKey = securecookie.GenerateRandomKey(64)
256+
var encryptionKey = securecookie.GenerateRandomKey(32)
257+
var store = sessions.NewCookieStore(authKey, encryptionKey)
251258

252259
func authMiddleware(next http.Handler) http.Handler {
253260
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {

0 commit comments

Comments
 (0)