Skip to content

Commit 129d143

Browse files
committed
fix(security): correct CSRF token expiration from nanoseconds to 1 hour
The CSRF Expiration was set to `3600` (integer) but Fiber's CSRF middleware expects a `time.Duration`. Go interpreted this as 3600 nanoseconds (~3.6 microseconds), causing tokens to expire instantly and all login attempts to fail with "CSRF token validation failed". Changed from `Expiration: 3600` to `Expiration: time.Hour`.
1 parent 60bf7e6 commit 129d143

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

internal/web/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ func createCSRFConfig(opts *options.Opts) *fiber.Handler {
188188
CookieSameSite: "Strict", // Strict for maximum security with proxy trust enabled
189189
CookieSecure: opts.CookieSecure, // Configurable based on HTTPS availability
190190
CookieHTTPOnly: true,
191-
Expiration: 3600, // 1 hour
191+
Expiration: time.Hour,
192192
KeyGenerator: csrf.ConfigDefault.KeyGenerator,
193193
ContextKey: "token", // Store token in c.Locals("token") for template access
194194
ErrorHandler: func(c *fiber.Ctx, err error) error {

0 commit comments

Comments
 (0)