Files
member-console/internal/db/migrations/00016_webhook_event_time.sql
T
cgalo5758 0b28a9dc29 Remediate security audit findings
- Replace gorilla/csrf with net/http CrossOriginProtection
- Require valkey-password and add TLS options for session store
- End session at /logout and revoke refresh tokens
- Re-derive identity and roles from provider every five minutes
- Process each Stripe webhook event in its own Temporal workflow
- Give each outbox entry its own workflow with Temporal retries
- Guard against stale Stripe events with provider timestamps
- Derive transport security from base-url scheme
2026-09-09 13:25:43 -05:00

21 lines
1012 B
SQL

-- SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
-- SPDX-FileCopyrightText: 2025-2026 Christian Galo
-- +goose Up
-- The provider's own timestamp for the event (Stripe's `created`), as
-- distinct from received_at, which is when it reached us. Stripe does not
-- guarantee delivery order; the product, price and customer handlers skip
-- an event when a completed event for the same object carries a later
-- provider time, and this column plus the index is that check. The object
-- id is the payload's own `id`, which the scrubber never touches. Rows from
-- before this migration keep NULL and are never treated as superseded.
ALTER TABLE core.webhook_events ADD COLUMN provider_event_at TIMESTAMPTZ;
CREATE INDEX idx_webhook_events_object_time
ON core.webhook_events (provider, (payload->>'id'), provider_event_at)
WHERE status = 'completed';
-- +goose Down
DROP INDEX IF EXISTS core.idx_webhook_events_object_time;
ALTER TABLE core.webhook_events DROP COLUMN provider_event_at;