Files
uptimesebi/internal/web/auth.templ
T
Sebastian UnterschützandClaude Opus 5.5 d7d4821e3e feat(api): enforce roles, org sign-in policies, invitations and api tokens
Every org route resolves a principal from the session or a bearer token
and checks a permission. Nobody can grant, revoke or remove more than
they hold. Tokens are capped by their owner's current rights and cannot
manage credentials. Orgs can require TOTP or SSO; the owner keeps a
password fallback for SSO.

Closes #6
Closes #7
Closes #8
Closes #9
Closes #41
Closes #45

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
2026-11-22 00:49:35 +01:00

60 lines
2.4 KiB
Templ

package web
import (
"git.zb-server.de/ZB-Server/uptimesebi/internal/auth"
"git.zb-server.de/ZB-Server/uptimesebi/internal/i18n"
)
templ Login(p Page, signupAllowed bool, next string) {
@authShell(p) {
<form data-api="/auth/login" data-next={ next }>
@formError()
<div data-step="password">
@field(i18n.T(ctx, "auth.field.email"), "email", "email", "username", true)
@field(i18n.T(ctx, "auth.field.password"), "password", "password", "current-password", true)
</div>
<div data-step="totp" hidden>
<p class="mb-4 text-sm text-muted">{ i18n.T(ctx, "auth.login.totp_hint") }</p>
@field(i18n.T(ctx, "auth.field.code"), "code", "text", "one-time-code", false)
</div>
@submit(i18n.T(ctx, "auth.login.submit"))
</form>
<form action="/sso" method="get" class="mt-10 border-t border-rule pt-6">
<p class="mb-3 text-xs font-medium uppercase tracking-wider text-muted">{ i18n.T(ctx, "auth.sso.heading") }</p>
<div class="flex gap-2">
<input
class="min-w-0 flex-1 border border-rule bg-transparent px-2.5 py-1.5 font-mono text-sm outline-none focus:border-ink"
name="org"
placeholder={ i18n.T(ctx, "auth.sso.org_placeholder") }
aria-label={ i18n.T(ctx, "auth.sso.org_placeholder") }
autocomplete="organization"
required
/>
<button type="submit" class="border border-ink px-3 py-1.5 text-sm hover:bg-ink hover:text-paper">{ i18n.T(ctx, "auth.sso.submit") }</button>
</div>
</form>
if signupAllowed {
<p class="mt-8 text-sm text-muted">
{ i18n.T(ctx, "auth.login.no_account") }
<a class="text-ink underline underline-offset-2" href="/signup">{ i18n.T(ctx, "auth.login.to_signup") }</a>
</p>
}
}
}
templ Signup(p Page) {
@authShell(p) {
<form data-api="/auth/signup" data-next="/">
@formError()
@field(i18n.T(ctx, "auth.field.name"), "display_name", "text", "name", false)
@field(i18n.T(ctx, "auth.field.email"), "email", "email", "username", true)
@field(i18n.T(ctx, "auth.field.new_password", "Min", auth.MinPasswordLength), "password", "password", "new-password", true)
<hr class="my-6 border-rule"/>
@field(i18n.T(ctx, "auth.field.org_name"), "org_name", "text", "organization", true)
@field(i18n.T(ctx, "auth.field.org_slug"), "org_slug", "text", "off", true)
@submit(i18n.T(ctx, "auth.signup.submit"))
</form>
<p class="mt-8 text-sm text-muted"><a class="text-ink underline underline-offset-2" href="/login">{ i18n.T(ctx, "auth.signup.to_login") }</a></p>
}
}