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.
33 lines
1.0 KiB
Go
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
|
|
}
|