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

+8
View File
@@ -99,6 +99,8 @@ type browser struct {
base string
hc *http.Client
csrf string
// bearer, if set, is sent as an API token instead of relying on cookies.
bearer string
}
func (e *env) browser(t *testing.T) *browser {
@@ -121,6 +123,9 @@ func (b *browser) do(method, path string, body any) (int, map[string]any) {
if b.csrf != "" {
req.Header.Set("X-CSRF-Token", b.csrf)
}
if b.bearer != "" {
req.Header.Set("Authorization", "Bearer "+b.bearer)
}
resp, err := b.hc.Do(req)
if err != nil {
b.t.Fatalf("%s %s failed: %v", method, path, err)
@@ -142,6 +147,9 @@ func (b *browser) visit(path string) *url.URL {
b.t.Fatalf("GET %s failed: %v", path, err)
}
_ = resp.Body.Close()
if resp.StatusCode != http.StatusOK {
b.t.Errorf("GET %s ended with status %d at %s", path, resp.StatusCode, resp.Request.URL)
}
return resp.Request.URL
}