feat: sign up and sign in with platform identity providers
Platform admins register identity providers for the whole installation: any OpenID Connect provider, checked by discovery, and GitHub or GitHub Enterprise through OAuth, which reads the primary email GitHub verified. Sign-in pages offer them; the sign-up page offers those open to sign-up, also where email sign-up is closed for lack of a mail server. Accounts are reached only through identities stored by subject. A new identity signs up only with an email the provider confirmed, within the per-address limit and sign-up mode, and never takes over an existing account, including through an alias of its address: its owner links the provider in the security settings. The account's TOTP still applies after the provider. Unlinking refuses to remove the last way to sign in, and removing a provider refuses while accounts depend on it. The test browser takes the CSRF token from pages, as the console does. Closes #114 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
1ad68e2e87
commit
fe5c4fb24c
26 files changed
+2710
-351
No files matched your search
@@ -101,7 +101,19 @@ type Identity struct {
|
||||
Email string
|
||||
}
|
||||
|
||||
templ Security(p Page, me Me, identities []Identity, canLink bool, activity []AuditEntry) {
|
||||
// PlatformIdentities are the platform providers an account signs in with
|
||||
// and those it could link.
|
||||
type PlatformIdentities struct {
|
||||
Linked []LinkedIdentity
|
||||
Available []IDPButton
|
||||
}
|
||||
|
||||
// LinkedIdentity is a platform provider linked to the account.
|
||||
type LinkedIdentity struct {
|
||||
ProviderID, Name, Email string
|
||||
}
|
||||
|
||||
templ Security(p Page, me Me, identities []Identity, canLink bool, activity []AuditEntry, platform PlatformIdentities) {
|
||||
@consoleShell(p, me) {
|
||||
<h1 class="mb-8 text-lg font-semibold">{ i18n.T(ctx, "security.title") }</h1>
|
||||
<section class="max-w-md">
|
||||
@@ -162,6 +174,34 @@ templ Security(p Page, me Me, identities []Identity, canLink bool, activity []Au
|
||||
<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>
|
||||
if len(platform.Linked)+len(platform.Available) > 0 {
|
||||
<section class="mt-12 max-w-md">
|
||||
<h2 class="mb-3 text-xs font-medium uppercase tracking-wider text-muted">{ i18n.T(ctx, "security.platform_sso.heading") }</h2>
|
||||
if len(platform.Linked) > 0 {
|
||||
<ul class="mb-4 divide-y divide-rule border-y border-rule text-sm">
|
||||
for _, l := range platform.Linked {
|
||||
<li class="flex items-center justify-between gap-4 py-2">
|
||||
<span>
|
||||
{ l.Name }
|
||||
<span class="block font-mono text-xs text-muted">{ l.Email }</span>
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
data-delete={ "/me/identities/" + l.ProviderID }
|
||||
data-confirm={ i18n.T(ctx, "security.platform_sso.unlink_confirm", "Name", l.Name) }
|
||||
class="text-muted hover:text-down"
|
||||
>{ i18n.T(ctx, "security.platform_sso.unlink") }</button>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
<div class="flex flex-wrap gap-2">
|
||||
for _, a := range platform.Available {
|
||||
<a href={ templ.SafeURL(a.URL) } class="border border-ink px-3 py-1.5 text-sm hover:bg-ink hover:text-paper">{ i18n.T(ctx, "security.platform_sso.link", "Name", a.Name) }</a>
|
||||
}
|
||||
</div>
|
||||
</section>
|
||||
}
|
||||
<section class="mt-12">
|
||||
@sectionHeading("security.activity")
|
||||
<p class="mb-4 max-w-2xl text-sm text-muted">{ i18n.T(ctx, "security.activity_intro") }</p>
|
||||
|
||||
Reference in new issue
Block a user