feat: implement B.1 — persist login sessions in SQLite with sliding idle timeout
Sessions move from an in-memory map (absolute 12h TTL) to a `sessions` table (migration 0002), storing only the SHA-256 of the token. Expiry is now a sliding idle window (PANEL_SESSION_IDLE_DAYS, default 7, no absolute cap), extended at most once an hour and never by the monitoring screens' background polling (GET + HX-Request), so a forgotten open tab doesn't keep a session alive indefinitely. A login now survives a container restart or redeploy. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -62,7 +62,7 @@ func TestSessionTokenIgnoresTheOtherName(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRequireAuthRejectsDuplicateCookies(t *testing.T) {
|
||||
s := &Server{cfg: Config{CookieSecure: false}, sessions: newSessionStore()}
|
||||
s := &Server{cfg: Config{CookieSecure: false}, sessions: newTestSessionStore(t)}
|
||||
token := s.sessions.Create("admin")
|
||||
|
||||
reached := false
|
||||
@@ -85,7 +85,7 @@ func TestRequireAuthRejectsDuplicateCookies(t *testing.T) {
|
||||
// Signing out has to expire the cookie under both names, or the cookie left
|
||||
// over from a pre-__Host- build stays in the browser for the rest of its life.
|
||||
func TestLogoutClearsBothCookieNames(t *testing.T) {
|
||||
s := &Server{cfg: Config{CookieSecure: true}, sessions: newSessionStore()}
|
||||
s := &Server{cfg: Config{CookieSecure: true}, sessions: newTestSessionStore(t)}
|
||||
token := s.sessions.Create("admin")
|
||||
|
||||
r := httptest.NewRequest(http.MethodPost, "http://panel.example.com/logout", nil)
|
||||
|
||||
Reference in New Issue
Block a user