feat(api): let each organization sign in through its own identity provider

Owners manage OIDC providers under /settings/sso. Users start at
/sso/<org>. New users can be provisioned for verified emails in allowed
domains; existing accounts are never matched by email and must link
their SSO sign-in while signed in.

Closes #4

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-22 00:30:43 +01:00
1 parent 9ad5f29f1b
commit 3f21361995
19 files changed
+2731 -231

No files matched your search

+15
View File
@@ -16,6 +16,7 @@ import (
"git.zb-server.de/ZB-Server/uptimesebi/internal/i18n"
"git.zb-server.de/ZB-Server/uptimesebi/internal/requestid"
"git.zb-server.de/ZB-Server/uptimesebi/internal/sealed"
"git.zb-server.de/ZB-Server/uptimesebi/internal/sso"
"git.zb-server.de/ZB-Server/uptimesebi/internal/store"
"git.zb-server.de/ZB-Server/uptimesebi/internal/tenant"
)
@@ -33,6 +34,7 @@ type Server struct {
sessions *auth.Sessions
limiter *auth.Limiter
totp *auth.TOTPVerifier
sso *sso.Client
}
// Deps are the external resources a Server needs.
@@ -46,6 +48,7 @@ type Deps struct {
// New returns a Server. It does not register any routes; see Mount.
func New(cfg config.API, d Deps) *Server {
allowPrivate := cfg.SSOAllowPrivate()
return &Server{
cfg: cfg,
log: d.Log,
@@ -56,6 +59,7 @@ func New(cfg config.API, d Deps) *Server {
sessions: auth.NewSessions(d.Redis, cfg.SessionIdle, cfg.SessionAbsolute),
limiter: auth.NewLimiter(d.Redis),
totp: auth.NewTOTPVerifier(d.Redis),
sso: sso.New(sso.SafeHTTPClient(allowPrivate), cfg.PublicURL+"/sso/callback", allowPrivate),
}
}
@@ -80,6 +84,17 @@ func (s *Server) Mount(r gin.IRouter) {
me.POST("/totp/enable", s.totpEnable)
me.POST("/totp/disable", s.totpDisable)
org := v1.Group("/org", auth.Require(), s.requireOwner())
org.GET("/sso", s.listSSOProviders)
org.POST("/sso", s.createSSOProvider)
org.PUT("/sso/:id", s.updateSSOProvider)
org.DELETE("/sso/:id", s.deleteSSOProvider)
g.GET("/sso", s.ssoLookup)
g.GET("/sso/callback", s.ssoCallback)
g.GET("/sso/:slug", s.ssoChoose)
g.GET("/sso/:slug/:provider", s.ssoStartProvider)
s.registerPages(g)
}