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
+16
-4
@@ -4,15 +4,16 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/api"
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/auth"
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/config"
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/migrations"
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/platform"
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/sealed"
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/tenant"
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/web"
|
||||
)
|
||||
|
||||
@@ -40,17 +41,28 @@ func run(log *slog.Logger, args []string) error {
|
||||
return errors.New("usage: api [serve | migrate up|down|status]")
|
||||
}
|
||||
|
||||
if err := cfg.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
keys, err := sealed.Parse(cfg.SecretKeys)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
deps, err := platform.Connect(ctx, cfg.Common, log)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer deps.Close()
|
||||
|
||||
srv := api.New(cfg, log, tenant.New(deps.DB), deps.Redis, keys)
|
||||
health := platform.NewHealth(deps.Probes())
|
||||
r := platform.NewRouter(log)
|
||||
health.Register(r)
|
||||
r.StaticFS("/static", web.Static())
|
||||
r.GET("/", func(c *gin.Context) { web.Render(c, http.StatusOK, web.Index()) })
|
||||
|
||||
app := r.Group("/", srv.Sessions().Load(), auth.CSRF())
|
||||
srv.Register(app)
|
||||
srv.RegisterPages(app)
|
||||
|
||||
return platform.Serve(ctx, log, platform.NewHTTPServer(cfg.Listen, r), health, 5*time.Second, cfg.ShutdownTimeout)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user