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
@@ -4,6 +4,9 @@ import "git.zb-server.de/ZB-Server/uptimesebi/internal/i18n"
|
||||
|
||||
// Me is the signed-in user as the console templates see it.
|
||||
type Me struct {
|
||||
// IsOwner refers to the active organization.
|
||||
IsOwner bool
|
||||
ActiveSlug string
|
||||
Email string
|
||||
DisplayName string
|
||||
TOTP bool
|
||||
@@ -35,6 +38,9 @@ templ consoleShell(p Page, me Me) {
|
||||
<span class="text-muted">{ me.Orgs[0].Name }</span>
|
||||
}
|
||||
<nav class="ml-auto flex items-center gap-5">
|
||||
if me.IsOwner {
|
||||
<a href="/settings/sso" class="text-muted hover:text-ink">{ i18n.T(ctx, "console.nav.sso") }</a>
|
||||
}
|
||||
<a href="/settings/security" class="text-muted hover:text-ink">{ i18n.T(ctx, "console.nav.security") }</a>
|
||||
<button data-logout class="text-muted hover:text-ink">{ i18n.T(ctx, "console.nav.logout") }</button>
|
||||
@languageSwitch(p.Languages)
|
||||
@@ -50,6 +56,7 @@ templ consoleShell(p Page, me Me) {
|
||||
</div>
|
||||
}
|
||||
<main class="mx-auto max-w-5xl px-6 py-10">
|
||||
@flash(p)
|
||||
{ children... }
|
||||
</main>
|
||||
}
|
||||
@@ -62,7 +69,13 @@ templ Dashboard(p Page, me Me) {
|
||||
}
|
||||
}
|
||||
|
||||
templ Security(p Page, me Me) {
|
||||
// Identity is an SSO sign-in linked to the user in the active organization.
|
||||
type Identity struct {
|
||||
Provider string
|
||||
Email string
|
||||
}
|
||||
|
||||
templ Security(p Page, me Me, identities []Identity, canLink bool) {
|
||||
@consoleShell(p, me) {
|
||||
<h1 class="mb-8 text-lg font-semibold">{ i18n.T(ctx, "security.title") }</h1>
|
||||
<section class="max-w-md">
|
||||
@@ -91,5 +104,20 @@ templ Security(p Page, me Me) {
|
||||
</div>
|
||||
}
|
||||
</section>
|
||||
<section class="mt-12 max-w-md">
|
||||
<h2 class="mb-3 text-xs font-medium uppercase tracking-wider text-muted">{ i18n.T(ctx, "security.sso.heading") }</h2>
|
||||
if len(identities) == 0 {
|
||||
<p class="mb-4 text-sm text-muted">{ i18n.T(ctx, "security.sso.none") }</p>
|
||||
} else {
|
||||
<ul class="mb-4 divide-y divide-rule border-y border-rule text-sm">
|
||||
for _, id := range identities {
|
||||
<li class="flex justify-between gap-4 py-2"><span>{ id.Provider }</span><span class="font-mono text-xs text-muted">{ id.Email }</span></li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
if canLink {
|
||||
<a href={ templ.SafeURL("/sso/" + me.ActiveSlug + "?link=1") } class="inline-block border border-ink px-3 py-1.5 text-sm hover:bg-ink hover:text-paper">{ i18n.T(ctx, "security.sso.link") }</a>
|
||||
}
|
||||
</section>
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user