feat: multi-tenancy, login, per-org SSO and i18n (M2) #46

Merged
Sebi merged 22 commits from feat/m2-tenancy into main 2026-11-21 23:44:17 +00:00
22 Commits
Author SHA1 Message Date
Sebastian UnterschützandClaude Opus 5.5 7b063d2cd8 feat(api): accept recovery codes as second factor and let users regenerate them
Enabling TOTP returns ten codes that are shown once. Disabling TOTP and
regenerating codes require the password plus a current code.

Closes #40

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
2026-11-22 00:35:20 +01:00
Sebastian UnterschützandClaude Opus 5.5 dbea42e7a5 feat(auth): add single-use totp recovery codes
Codes are stored as SHA-256 hashes and consumed with one conditional
update, so concurrent use of the same code succeeds at most once.

Refs #40

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
2026-11-22 00:35:20 +01:00
Sebastian UnterschützandClaude Opus 5.5 3f21361995 feat(api): let each organization sign in through its own identity provider
Owners manage OIDC providers under /settings/sso. Users start at
/sso/<org>. New users can be provisioned for verified emails in allowed
domains; existing accounts are never matched by email and must link
their SSO sign-in while signed in.

Closes #4

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
2026-11-22 00:30:43 +01:00
Sebastian UnterschützandClaude Opus 5.5 9ad5f29f1b feat(sso): add openid connect client with pkce and guarded discovery
Issuer URLs come from customers, so requests to their IdPs refuse
non-public addresses unless private networks are explicitly allowed.

Refs #4

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
2026-11-22 00:30:43 +01:00
Sebastian UnterschützandClaude Opus 5.5 d1976ed57a feat(store): add per-organization sso providers and linked identities
Identities are keyed by provider and subject. Both tables are tenant
scoped; org_id_by_slug resolves a slug before sign-in without opening a
broader scope.

Refs #4

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
2026-11-22 00:30:43 +01:00
Sebastian UnterschützandClaude Opus 5.5 c485d1a96f feat(platform): tag requests, logs and api errors with a request id
A well-formed X-Request-ID from a proxy is kept, otherwise a UUIDv7 is
generated. The ID is echoed in the response header, added to every log
record written with the request context and returned in API error
bodies.

Closes #44

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
2026-11-22 00:20:57 +01:00
Sebastian UnterschützandClaude Opus 5.5 b6843330a8 test: report failures as got/want and use subtests for tables
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
2026-11-22 00:18:02 +01:00
Sebastian UnterschützandClaude Opus 5.5 d20225982a refactor: follow the google go style guide
Document every package and exported identifier, return the log level
from NewLogger instead of keeping it in a package variable, and stop
tests from mutating the argon2 parameters.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
2026-11-22 00:18:02 +01:00
Sebastian UnterschützandClaude Opus 5.5 048e114fd9 build: add golangci-lint configuration
staticcheck and unused stay disabled until honnef.co/go/tools supports
the Go 1.27 standard library.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
2026-11-22 00:18:02 +01:00
Sebastian UnterschützandClaude Opus 5.5 ea6f022112 fix(config): reject an empty checker region
UPTIME_CHECKER_REGION= passed the required check and started a checker
that no monitor could ever be assigned to.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
2026-11-22 00:18:02 +01:00
Sebastian UnterschützandClaude Opus 5.5 70190446ff feat(api): localize console pages and api error messages
The language comes from the user setting, then the lang cookie, then
Accept-Language, falling back to English. Errors keep a stable code and
carry a translated message.

Closes #42

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
2026-11-22 00:07:00 +01:00
Sebastian UnterschützandClaude Opus 5.5 dde7b890b8 feat(auth): persist preferred language per user and session
Refs #42

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
2026-11-22 00:07:00 +01:00
Sebastian UnterschützandClaude Opus 5.5 7dd1f87ffe feat(i18n): add english and german message catalogs
Tests fail on catalogs with diverging keys and on message IDs used in
code or templates that no catalog defines.

Refs #42

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
2026-11-22 00:07:00 +01:00
Sebastian UnterschützandClaude Opus 5.5 db44fedc72 feat(api): add signup, login with totp and account security pages
Signup is limited to the first user by default (UPTIME_SIGNUP). TOTP
secrets are sealed with UPTIME_SECRET_KEYS and bound to the user id.

Closes #3
Closes #5

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
2026-11-21 23:55:23 +01:00
Sebastian UnterschützandClaude Opus 5.5 99e9b1e57d feat(store): add totp columns, org totp policy and global scope
Orgs are created inside their own tenant scope, so signup needs no
system scope.

Refs #3

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
2026-11-21 23:55:23 +01:00
Sebastian UnterschützandClaude Opus 5.5 caff396264 feat(auth): add argon2id passwords, replay-safe totp and redis rate limits
Refs #3

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
2026-11-21 23:55:23 +01:00
Sebastian UnterschützandClaude Opus 5.5 96c1555889 feat(sealed): encrypt secrets at rest with a rotatable keyring
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
2026-11-21 23:55:23 +01:00
Sebastian UnterschützandClaude Opus 5.5 9667e121f1 feat(auth): add session middleware and csrf protection
Unsafe methods require the session's synchronizer token and a matching
Origin, which also covers login requests that have no session yet.

Refs #5

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
2026-11-21 23:49:08 +01:00
Sebastian UnterschützandClaude Opus 5.5 dae55d8c18 feat(auth): store sessions in redis with sliding and absolute expiry
Tokens are only kept as SHA-256 hashes. A per-user index allows ending
all sessions of an account at once.

Closes #1

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
2026-11-21 23:49:08 +01:00
Sebastian UnterschützandClaude Opus 5.5 ccc0fe58b8 feat(tenant): enforce tenant isolation with row-level security
Every query runs inside a transaction carrying app.org_id, app.user_id
or the explicit system scope. Without a scope no rows are visible.

Closes #2

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
2026-11-21 23:48:02 +01:00
Sebastian UnterschützandClaude Opus 5.5 95da376ac1 feat(store): add users and org memberships with single owner per org
Refs #1

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
2026-11-21 23:48:02 +01:00
Sebastian UnterschützandClaude Opus 5.5 c615c21af1 build(dev): connect as non-superuser role so row-level security applies
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
2026-11-21 23:48:02 +01:00