Adding time.Second-1 to MEALQUEST_SESSION_MAX overflowed time.Duration
near its largest accepted value, giving a negative MaxAge that net/http
sends as Max-Age=0. Divide by time.Second and increment the quotient
when there is a remainder instead.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A maximum session lifetime with fractional seconds (e.g. 2500ms) was
truncated to a 2-second cookie Max-Age, so the browser dropped the
cookie before the server-side absolute limit. Round up instead; the
stored expires_at keeps the configured duration.
Fixes review finding MQ-19-2.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A successful OIDC callback now creates a sessions row through the new
auth.SessionManager: a random 256-bit ID whose SHA-256 hash is the only
stored form, the subject, email, name and groups claims, a separate random
CSRF token and created/last_seen/expires timestamps. The ID travels only in
the __Host-mealquest_session cookie (HttpOnly, Secure, SameSite=Lax, Path=/,
no Domain).
SessionFor rejects a session unused for MEALQUEST_SESSION_IDLE or older
than MEALQUEST_SESSION_MAX, deletes it, and otherwise slides last_seen_at.
POST /auth/logout deletes the row, clears the cookie and redirects to the
provider's end_session_endpoint, which discovery now requires.
The session lifetimes are optional configuration (defaults 720h and 4320h,
per D-004); set values must be positive with MAX at least IDLE.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>