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
This commit is contained in:
1 parent
30409697f7
commit
d7d4821e3e
24 files changed
+4677
-439
No files matched your search
+14
-3
@@ -28,6 +28,7 @@ type SSOProvider struct {
|
||||
HasSecret bool
|
||||
AllowedDomains string
|
||||
AutoProvision bool
|
||||
DefaultRoleID string
|
||||
Enabled bool
|
||||
}
|
||||
|
||||
@@ -36,6 +37,7 @@ type SSOSettings struct {
|
||||
Providers []SSOProvider
|
||||
RedirectURL string
|
||||
LoginURL string
|
||||
Roles []Role
|
||||
}
|
||||
|
||||
templ SSOSettingsPage(p Page, me Me, s SSOSettings) {
|
||||
@@ -70,7 +72,7 @@ templ SSOSettingsPage(p Page, me Me, s SSOSettings) {
|
||||
<details class="inline-block text-left">
|
||||
<summary class="cursor-pointer text-muted hover:text-ink">{ i18n.T(ctx, "sso.action.edit") }</summary>
|
||||
<div class="mt-4 w-80">
|
||||
@ssoForm(pr, "put", "/org/sso/"+pr.ID)
|
||||
@ssoForm(pr, s.Roles, "put", "/org/sso/"+pr.ID)
|
||||
<button
|
||||
type="button"
|
||||
data-delete={ "/org/sso/" + pr.ID }
|
||||
@@ -87,7 +89,7 @@ templ SSOSettingsPage(p Page, me Me, s SSOSettings) {
|
||||
}
|
||||
<section class="max-w-md">
|
||||
<h2 class="mb-4 text-xs font-medium uppercase tracking-wider text-muted">{ i18n.T(ctx, "sso.settings.add") }</h2>
|
||||
@ssoForm(SSOProvider{Enabled: true}, "post", "/org/sso")
|
||||
@ssoForm(SSOProvider{Enabled: true}, s.Roles, "post", "/org/sso")
|
||||
</section>
|
||||
}
|
||||
}
|
||||
@@ -100,7 +102,7 @@ templ yesNo(v bool) {
|
||||
}
|
||||
}
|
||||
|
||||
templ ssoForm(pr SSOProvider, method, action string) {
|
||||
templ ssoForm(pr SSOProvider, roles []Role, method, action string) {
|
||||
<form data-api={ action } data-method={ method } data-next="/settings/sso">
|
||||
@formError()
|
||||
@valueField(i18n.T(ctx, "sso.field.name"), "name", pr.Name, "", true)
|
||||
@@ -130,6 +132,15 @@ templ ssoForm(pr SSOProvider, method, action string) {
|
||||
<span class="mt-1 block text-xs text-muted">{ i18n.T(ctx, "sso.field.allowed_domains_hint") }</span>
|
||||
</label>
|
||||
@checkbox(i18n.T(ctx, "sso.field.auto_provision"), "auto_provision", pr.AutoProvision)
|
||||
<label class="mb-4 block">
|
||||
<span class="mb-1 block text-xs font-medium uppercase tracking-wider text-muted">{ i18n.T(ctx, "sso.field.default_role") }</span>
|
||||
<select name="default_role_id" data-nullable class="w-full border border-rule bg-transparent px-2 py-1.5 text-sm">
|
||||
<option value="">{ i18n.T(ctx, "sso.field.default_role_viewer") }</option>
|
||||
for _, r := range roles {
|
||||
<option value={ r.ID } selected?={ r.ID == pr.DefaultRoleID }>{ r.Name }</option>
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
@checkbox(i18n.T(ctx, "sso.field.enabled"), "enabled", pr.Enabled)
|
||||
@submit(i18n.T(ctx, "common.save"))
|
||||
</form>
|
||||
|
||||
Reference in new issue
Block a user