diff options
| author | Leonardo Bishop <me@leonardobishop.com> | 2025-01-26 00:29:46 +0000 |
|---|---|---|
| committer | Leonardo Bishop <me@leonardobishop.com> | 2025-01-26 00:29:46 +0000 |
| commit | dd49c9205bb04844b686b9c3396c40eb49d25826 (patch) | |
| tree | babd1d90a939a7928ef02e9656ddf6ee22104f92 /api/router.go | |
| parent | 0d0a02766a59729f61c48f00e71bdae91ed64482 (diff) | |
Add alarms to calendar events
Diffstat (limited to 'api/router.go')
| -rw-r--r-- | api/router.go | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/api/router.go b/api/router.go index dc7e487..99c79c7 100644 --- a/api/router.go +++ b/api/router.go @@ -1,6 +1,8 @@ package api import ( + "crypto/rand" + "encoding/hex" "errors" "log/slog" "time" @@ -27,9 +29,11 @@ type ApiServices struct { func NewServer(apiServices ApiServices, baseURL string) *fiber.App { sessionStore := session.New(session.Config{ - Expiration: 24 * time.Hour, + Expiration: 7 * 24 * time.Hour, + KeyGenerator: generateSessionToken, KeyLookup: "cookie:confplanner_session", - CookieSameSite: "None", + CookieSameSite: "Strict", + CookieSecure: true, }) app := fiber.New(fiber.Config{ @@ -74,3 +78,11 @@ func NewServer(apiServices ApiServices, baseURL string) *fiber.App { return app } + +func generateSessionToken() string { + b := make([]byte, 100) + if _, err := rand.Read(b); err != nil { + return "" + } + return hex.EncodeToString(b) +} |
