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:
1 parent
9ad5f29f1b
commit
3f21361995
19 files changed
+2731
-231
No files matched your search
@@ -5,6 +5,8 @@ package config
|
||||
import (
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"net/url"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/caarlos0/env/v11"
|
||||
@@ -61,6 +63,22 @@ type API struct {
|
||||
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"`
|
||||
// PublicURL is the externally reachable base URL, used for SSO callbacks.
|
||||
PublicURL string `env:"UPTIME_PUBLIC_URL" envDefault:"http://localhost:8080"`
|
||||
// SSOPrivateNetworks is "auto", "true" or "false". Auto allows
|
||||
// organizations' IdPs on private networks only in the self-hosted edition.
|
||||
SSOPrivateNetworks string `env:"UPTIME_SSO_ALLOW_PRIVATE_NETWORKS" envDefault:"auto"`
|
||||
}
|
||||
|
||||
// SSOAllowPrivate resolves SSOPrivateNetworks.
|
||||
func (a API) SSOAllowPrivate() bool {
|
||||
switch a.SSOPrivateNetworks {
|
||||
case "true":
|
||||
return true
|
||||
case "false":
|
||||
return false
|
||||
}
|
||||
return a.Edition == EditionSelfHosted
|
||||
}
|
||||
|
||||
// Validate checks API-specific settings in addition to Common.Validate.
|
||||
@@ -76,6 +94,14 @@ func (a API) Validate() error {
|
||||
default:
|
||||
return fmt.Errorf("config: unknown UPTIME_SIGNUP %q", a.Signup)
|
||||
}
|
||||
switch a.SSOPrivateNetworks {
|
||||
case "auto", "true", "false":
|
||||
default:
|
||||
return fmt.Errorf("config: UPTIME_SSO_ALLOW_PRIVATE_NETWORKS must be auto, true or false")
|
||||
}
|
||||
if u, err := url.Parse(a.PublicURL); err != nil || u.Host == "" || (u.Scheme != "https" && u.Scheme != "http") || strings.HasSuffix(a.PublicURL, "/") {
|
||||
return fmt.Errorf("config: UPTIME_PUBLIC_URL must be an absolute http(s) URL without trailing slash")
|
||||
}
|
||||
if a.SessionIdle <= 0 || a.SessionAbsolute < a.SessionIdle {
|
||||
return fmt.Errorf("config: UPTIME_SESSION_ABSOLUTE must be >= UPTIME_SESSION_IDLE > 0")
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user