-- Migration 011: OIDC admin login + built-in IndieAuth server -- Version: 2.0.0 -- Per ADR-064: Replace IndieAuth login with OIDC, issue Micropub tokens locally -- -- New tables only. The legacy auth_state, tokens and authorization_codes -- tables are left alone: INITIAL_SCHEMA_SQL recreates tokens and -- authorization_codes on every start while migration 004 drops them, so -- nothing new can depend on them. -- Pending OIDC logins (state, nonce and PKCE verifier for one round trip) CREATE TABLE IF NOT EXISTS oidc_login_state ( state TEXT PRIMARY KEY, nonce TEXT NOT NULL, code_verifier TEXT NOT NULL, next_url TEXT, created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, expires_at TIMESTAMP NOT NULL ); CREATE INDEX IF NOT EXISTS idx_oidc_login_state_expires ON oidc_login_state(expires_at); -- Authorization codes issued to IndieAuth (Micropub) clients CREATE TABLE IF NOT EXISTS indieauth_codes ( id INTEGER PRIMARY KEY AUTOINCREMENT, code_hash TEXT UNIQUE NOT NULL, client_id TEXT NOT NULL, redirect_uri TEXT NOT NULL, scope TEXT NOT NULL DEFAULT '', code_challenge TEXT NOT NULL, created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, expires_at TIMESTAMP NOT NULL, used_at TIMESTAMP ); CREATE INDEX IF NOT EXISTS idx_indieauth_codes_expires ON indieauth_codes(expires_at); -- Access tokens issued to IndieAuth (Micropub) clients CREATE TABLE IF NOT EXISTS indieauth_tokens ( id INTEGER PRIMARY KEY AUTOINCREMENT, token_hash TEXT UNIQUE NOT NULL, client_id TEXT NOT NULL, scope TEXT NOT NULL, created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, expires_at TIMESTAMP NOT NULL, last_used_at TIMESTAMP, revoked_at TIMESTAMP ); CREATE INDEX IF NOT EXISTS idx_indieauth_tokens_expires ON indieauth_tokens(expires_at);