-- Adds support for federated/SSO login (OIDC) alongside local username+password accounts. Only -- one external identity provider is modeled today: the University of Ljubljana (backed by -- Microsoft Entra ID in production; a throwaway local Authentik instance stands in for it in dev -- - see dev/authentik/). The auth_provider enum intentionally has just these two values. CREATE TYPE auth_provider AS ENUM ('local', 'uni_lj'); -- SSO-only users are authenticated entirely by the external IdP and never set a local password. ALTER TABLE "user" ALTER COLUMN bcrypt_hash DROP NOT NULL; CREATE TABLE user_external_identity ( auth_provider auth_provider NOT NULL, subject VARCHAR NOT NULL, user_id INT NOT NULL REFERENCES "user", time_linked TIMESTAMPTZ NOT NULL DEFAULT NOW(), PRIMARY KEY (auth_provider, subject), UNIQUE (user_id, auth_provider) );