feat(api): add signup, login with totp and account security pages
Signup is limited to the first user by default (UPTIME_SIGNUP). TOTP secrets are sealed with UPTIME_SECRET_KEYS and bound to the user id. Closes #3 Closes #5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
1 parent
99e9b1e57d
commit
db44fedc72
18 files changed
+1792
-91
No files matched your search
@@ -35,9 +35,39 @@ type Sentinel struct {
|
||||
|
||||
func (s Sentinel) Enabled() bool { return s.Master != "" }
|
||||
|
||||
type SignupMode string
|
||||
|
||||
const (
|
||||
SignupOpen SignupMode = "open"
|
||||
SignupFirstUser SignupMode = "first-user"
|
||||
SignupClosed SignupMode = "closed"
|
||||
)
|
||||
|
||||
type API struct {
|
||||
Common
|
||||
Listen string `env:"UPTIME_API_LISTEN" envDefault:":8080"`
|
||||
Listen string `env:"UPTIME_API_LISTEN" envDefault:":8080"`
|
||||
SecretKeys string `env:"UPTIME_SECRET_KEYS"`
|
||||
Signup SignupMode `env:"UPTIME_SIGNUP" envDefault:"first-user"`
|
||||
SessionIdle time.Duration `env:"UPTIME_SESSION_IDLE" envDefault:"168h"`
|
||||
SessionAbsolute time.Duration `env:"UPTIME_SESSION_ABSOLUTE" envDefault:"720h"`
|
||||
}
|
||||
|
||||
func (a API) Validate() error {
|
||||
if err := a.Common.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
if a.SecretKeys == "" {
|
||||
return fmt.Errorf("config: UPTIME_SECRET_KEYS is required (format id:base64-32-bytes)")
|
||||
}
|
||||
switch a.Signup {
|
||||
case SignupOpen, SignupFirstUser, SignupClosed:
|
||||
default:
|
||||
return fmt.Errorf("config: unknown UPTIME_SIGNUP %q", a.Signup)
|
||||
}
|
||||
if a.SessionIdle <= 0 || a.SessionAbsolute < a.SessionIdle {
|
||||
return fmt.Errorf("config: UPTIME_SESSION_ABSOLUTE must be >= UPTIME_SESSION_IDLE > 0")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Checker struct {
|
||||
|
||||
Reference in new issue
Block a user