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:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-22 00:49:35 +01:00
1 parent 30409697f7
commit d7d4821e3e
24 files changed
+4677 -439

No files matched your search

+20 -3
View File
@@ -17,13 +17,22 @@
el.classList.toggle("hidden", !text);
};
// Inputs inside a hidden [data-step] are skipped, checkboxes become
// booleans and [data-list] inputs become comma-separated arrays.
// Inputs inside a hidden [data-step] are skipped. Checkboxes become
// booleans, or arrays of values with [data-multi]; [data-list] inputs are
// split on commas, [data-number] parsed and empty [data-nullable] sent as null.
const serialize = (form) => {
const out = {};
for (const el of form.elements) {
if (!el.name || el.disabled || el.closest("[data-step]")?.hidden) continue;
if (!el.name || el.closest("[data-step]")?.hidden) continue;
if (el.dataset.multi !== undefined) {
out[el.name] ??= [];
if (el.checked && !el.disabled) out[el.name].push(el.value);
continue;
}
if (el.disabled) continue;
if (el.type === "checkbox") out[el.name] = el.checked;
else if (el.dataset.number !== undefined) out[el.name] = Number(el.value);
else if (el.dataset.nullable !== undefined) out[el.name] = el.value || null;
else if (el.dataset.list !== undefined)
out[el.name] = el.value.split(",").map((v) => v.trim()).filter(Boolean);
else out[el.name] = el.value;
@@ -54,6 +63,14 @@
out.hidden = false;
return;
}
if (form.dataset.showLink !== undefined && (res.data?.url || res.data?.token)) {
const out = form.querySelector("[data-link-output]");
const input = out.querySelector("[data-link]");
input.value = res.data.url || res.data.token;
out.hidden = false;
input.select();
return;
}
if (res.data?.status === "totp_required" && totpStep) {
form.querySelector('[data-step="password"]').hidden = true;
totpStep.hidden = false;