Harden compliance portal auth and TLS

Align console references and OAuth branding with the
compliance-page model, and fix certificate cache eviction,
portal OAuth handlers, and magic-link edge cases left after
the trust-center rename.

Signed-off-by: Bryan Frimin <bryan@probo.com>
This commit is contained in:
Bryan Frimin
2026-07-20 09:59:25 +02:00
parent b03acbd029
commit 43ce3a7c53
51 changed files with 626 additions and 458 deletions

View File

@@ -24,6 +24,7 @@ INSERT INTO trust_centers (
tenant_id,
active,
slug,
search_engine_indexing,
created_at,
updated_at
)
@@ -41,6 +42,7 @@ SELECT
'\s+', '-', 'g'
)
),
'NOT_INDEXABLE',
NOW(),
NOW()
FROM organizations o

View File

@@ -25,7 +25,7 @@ CREATE TABLE certificates (
ssl_certificate_chain TEXT,
status custom_domain_ssl_status NOT NULL,
ssl_expires_at TIMESTAMP WITH TIME ZONE,
ssl_retry_count INTEGER NOT NULL DEFAULT 0,
ssl_retry_count INTEGER NOT NULL,
ssl_last_attempt_at TIMESTAMP WITH TIME ZONE,
http_challenge_token TEXT,
http_challenge_key_auth TEXT,
@@ -100,6 +100,12 @@ SET certificate_id = cd.certificate_id
FROM custom_domains cd
WHERE cd.id = cc.custom_domain_id;
-- Entries that could not be repointed (stale custom_domain_id, or a domain
-- whose certificate was never migrated) are unusable cache rows; drop them
-- rather than leaving certificate_id NULL for callers that always expect it.
DELETE FROM cached_certificates WHERE certificate_id IS NULL;
ALTER TABLE cached_certificates ALTER COLUMN certificate_id SET NOT NULL;
ALTER TABLE cached_certificates DROP COLUMN custom_domain_id;
-- Drop the certificate lifecycle columns now living on certificates.

View File

@@ -29,6 +29,19 @@ WITH pending_pages AS (
FROM trust_centers tc
WHERE tc.default_domain_id IS NULL
AND NULLIF(current_setting('probo.trust_center_base_domain', true), '') IS NOT NULL
-- Skip hostnames that already exist: minting a certificate or custom
-- domain for them would violate their unique constraints and abort
-- the whole migration.
AND NOT EXISTS (
SELECT 1
FROM certificates c
WHERE c.hostname = (tc.slug || '.' || current_setting('probo.trust_center_base_domain', true))::citext
)
AND NOT EXISTS (
SELECT 1
FROM custom_domains cd
WHERE cd.domain = (tc.slug || '.' || current_setting('probo.trust_center_base_domain', true))::citext
)
),
minted_certificates AS (
INSERT INTO certificates (

View File

@@ -17,5 +17,5 @@
UPDATE trust_centers
SET
slug = slug || '-' || encode(gen_random_bytes(4), 'hex'),
slug = slug || '-' || encode(gen_random_bytes(16), 'hex'),
updated_at = clock_timestamp();