Files
pages/internal/store/auth_session_policy.go
T
Anya Tokugawa d5d21b7841
Build and publish container images / images (push) Successful in 9m34s
Release container images / release (push) Successful in 36s
Refactor architecture into eight components and consolidate reliability work
Extract Grammaratur, Dregarnuhr, Geduldh, Mestionora, Ordoschnellic, Schutzaria, Kunstzeal and Seheweit behind compatible application contracts.

Include accumulated editor resilience, navigation and theme UX, remote CLI, storage/schema and DR groundwork, tests and design/operations documentation.

Verified: uncached full Go suite; go vet ./...; race tests for all eight components; 11 targeted Chromium tests; Node suites; 19 Python CLI tests; reproducible editor build. No push, release tag or deployment in this checkpoint.
2026-11-01 15:23:31 +09:00

33 lines
1.0 KiB
Go

package store
import (
"errors"
"strconv"
"time"
)
const DefaultAuthSessionMinutes = 24 * 60
const MaxAuthSessionMinutes = 30 * 24 * 60
// Absolute lifetime, fixed at issuance. Changing the policy cannot silently
// revive, extend or invalidate existing sessions. App passwords are separate.
func (s *Store) AuthSessionLifetimeMinutes(domain string) int {
raw, err := s.GetConfigInDomain(domain, "auth_session_minutes")
value, parseErr := strconv.Atoi(raw)
if err != nil || parseErr != nil || value < 5 || value > MaxAuthSessionMinutes {
return DefaultAuthSessionMinutes
}
return value
}
func (s *Store) SetAuthSessionLifetimeMinutes(domain string, minutes int) error {
if minutes < 5 || minutes > MaxAuthSessionMinutes {
return errors.New("session lifetime must be between 5 and 43200 minutes")
}
return s.SetConfigInDomain(domain, "auth_session_minutes", strconv.Itoa(minutes))
}
func (s *Store) AuthSessionLifetime(domain string) time.Duration {
return time.Duration(s.AuthSessionLifetimeMinutes(domain)) * time.Minute
}