aboutsummaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorLeonardo Bishop <me@leonardobishop.com>2025-01-26 00:29:46 +0000
committerLeonardo Bishop <me@leonardobishop.com>2025-01-26 00:29:46 +0000
commitdd49c9205bb04844b686b9c3396c40eb49d25826 (patch)
treebabd1d90a939a7928ef02e9656ddf6ee22104f92 /api
parent0d0a02766a59729f61c48f00e71bdae91ed64482 (diff)
Add alarms to calendar events
Diffstat (limited to 'api')
-rw-r--r--api/handlers/ical.go1
-rw-r--r--api/router.go16
2 files changed, 15 insertions, 2 deletions
diff --git a/api/handlers/ical.go b/api/handlers/ical.go
index c4b3989..52dfcdb 100644
--- a/api/handlers/ical.go
+++ b/api/handlers/ical.go
@@ -38,6 +38,7 @@ func GetIcal(icalService ical.Service, calendarService calendar.Service) fiber.H
return err
}
+ c.Set("Content-Type", "text/calendar")
return c.SendString(ical)
}
}
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)
+}