IAM-13: oidc-provider-fuer-drittanwendungen (client-registrierung, authorization-code-flow, jwks ueber API-05-schluessel)

This commit is contained in:
sysops
2026-08-28 23:25:45 +02:00
parent f7863fd4d2
commit 42466c7b40
6 changed files with 833 additions and 0 deletions
@@ -0,0 +1,2 @@
DROP TABLE oidc_auth_codes;
DROP TABLE oidc_clients;
@@ -0,0 +1,28 @@
-- IAM-13: NEXARCH als OIDC-Provider fuer Drittanwendungen eines Mandanten.
-- Client-Registrierung und Authorization-Codes leben pro Mandant (nicht in
-- der zentralen Registry), weil ein OAuth2-Client konzeptionell zu genau
-- einem Kunden gehoert (siehe core-kanban/tickets/IAM-13.md).
CREATE TABLE oidc_clients (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
name TEXT NOT NULL,
client_id TEXT NOT NULL UNIQUE,
secret_hash BYTEA NOT NULL,
redirect_uris TEXT[] NOT NULL,
allowed_scopes TEXT[] NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
-- Auth-Codes sind bewusst kurzlebig und einmal verwendbar (RFC 6749 4.1.2):
-- used_at IS NULL in der WHERE-Klausel beim Einloesen macht das Konsumieren
-- atomar, gleiches Muster wie internal/authtoken (IAM-03).
CREATE TABLE oidc_auth_codes (
code_hash BYTEA PRIMARY KEY,
client_id TEXT NOT NULL REFERENCES oidc_clients(client_id),
user_id UUID NOT NULL REFERENCES users(id),
redirect_uri TEXT NOT NULL,
scopes TEXT[] NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
expires_at TIMESTAMPTZ NOT NULL,
used_at TIMESTAMPTZ
);