Repository navigation
WPB-22966: migrate oauth auth-code to PostGreSQL - #5622
Open
blackheaven wants to merge 7 commits into
Open
blackheaven wants to merge 7 commits into
blackheaven wants to merge 7 commits into
Conversation
blackheaven
force-pushed
the
gdifolco/WPB-22966-migration-postgres-oauth-auth-code
branch
from
October 20, 2026 23:58
0cde656 to
6f14a1c
Compare
blackheaven
force-pushed
the
gdifolco/WPB-22966-migration-postgres-oauth-auth-code
branch
2 times, most recently
from
November 4, 2026 12:50
c5bab57 to
de55a54
Compare
blackheaven
force-pushed
the
gdifolco/WPB-22966-migration-postgres-oauth-auth-code
branch
from
November 5, 2026 12:53
de55a54 to
7ccf775
Compare
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Critical schema and backfill defects invalidate the SQL dump, block migration completion, and risk reactivating redeemed or expired authorization codes.
7 open issues
Preserve source expiration deadlines during backfill · New Prevent stale backfill copies from restoring redeemed codes · New Read TTL from a non-primary-key column · New Ignore duplicate backfill inserts without refreshing expiration · New Restore the closed nonce table definition · New Create the OAuth test user on the migrated backend · New Use Brig’s actual JSON path for the OAuth code expiration setting · New
What changed in this PR
This PR adds PostgreSQL storage for OAuth authorization codes, moving Brig’s persistence logic behind a shared store abstraction with Cassandra, dual-write, and PostgreSQL modes.
Changes:
- Adds the authorization-code store, PostgreSQL schema, and serialization support.
- Wires background migration, metrics, configuration, and deployment settings.
- Adds migration lifecycle and serialization tests, documentation, and a changelog entry.
| File | Description |
|---|---|
| services/galley/galley.integration.yaml | Adds the authorization-code storage setting. |
| services/brig/src/Brig/CanonicalInterpreter.hs | Selects the configured store interpreter. |
| services/brig/src/Brig/API/Public.hs | Adds the store effect requirement. |
| services/brig/src/Brig/API/OAuth.hs | Routes authorization-code operations through the store. |
| services/brig/brig.integration.yaml | Selects PostgreSQL for integration testing. |
| services/background-worker/test/Test/Wire/Util.hs | Updates test migration options. |
| services/background-worker/test/Test/Wire/BackendNotificationPusherSpec.hs | Updates migration-option fixtures. |
| services/background-worker/src/Wire/PostgresMigrations.hs | Adds migration startup and metrics. |
| services/background-worker/src/Wire/BackgroundWorker/Options.hs | Adds the migration enablement flag. |
| services/background-worker/src/Wire/BackgroundWorker.hs | Wires migration startup and cleanup. |
| services/background-worker/background-worker.integration.yaml | Adds integration migration settings. |
| postgres-schema.sql | Updates the schema snapshot. |
| libs/wire-subsystems/wire-subsystems.cabal | Exposes the new store modules. |
| libs/wire-subsystems/src/Wire/PostgresMigrationOpts.hs | Adds storage-mode configuration. |
| libs/wire-subsystems/src/Wire/OAuthAuthCodeStore/Postgres.hs | Implements PostgreSQL insertion and atomic consumption. |
| libs/wire-subsystems/src/Wire/OAuthAuthCodeStore/Migration.hs | Implements Cassandra-to-PostgreSQL backfill. |
| libs/wire-subsystems/src/Wire/OAuthAuthCodeStore/DualWrite.hs | Mirrors writes and consumption during migration. |
| libs/wire-subsystems/src/Wire/OAuthAuthCodeStore/Cassandra.hs | Extracts existing Cassandra persistence. |
| libs/wire-subsystems/src/Wire/OAuthAuthCodeStore.hs | Defines the authorization-code store effect. |
| libs/wire-subsystems/postgres-migrations/20261020120000-oauth-auth-code.sql | Creates the table and expiration index. |
| libs/wire-api/test/unit/Test/Wire/API/Roundtrip/PostgresMarshall.hs | Adds OAuth serialization round-trip tests. |
| libs/wire-api/src/Wire/API/OAuth.hs | Adds PostgreSQL serialization instances. |
| integration/test/Test/Migration/OAuthAuthCode.hs | Adds migration lifecycle and replay assertions. |
| integration/integration.cabal | Registers the migration test module. |
| hack/helm_vars/wire-server/values.yaml.gotmpl | Passes the selected storage mode into Helm values. |
| hack/helm_vars/common.yaml.gotmpl | Defines the preferred authorization-code store. |
| docs/src/developer/reference/config-options.md | Documents configuration and migration controls. |
| charts/wire-server/values.yaml | Adds default storage and migration settings. |
| charts/wire-server/templates/background-worker/configmap.yaml | Renders the migration flag. |
| changelog.d/5-internal/WPB-22966 | Records the storage migration. |
Review effort: Balanced
blackheaven
force-pushed
the
gdifolco/WPB-22966-migration-postgres-oauth-auth-code
branch
from
November 10, 2026 08:54
af078e2 to
638f9fb
Compare
- Backfill: read ttl(client) instead of ttl(code) (Cassandra rejects ttl() on key columns); capture one absolute deadline per page so buffered rows cannot outlive their source TTL; skip rows whose deadline already passed; probe Cassandra liveness before inserting so codes consumed while buffered are not resurrected in Postgres. - insertOAuthAuthCodePg takes an absolute expires_at and inserts with ON CONFLICT (code) DO NOTHING; interpreter computes now + ttl. - postgres-schema.sql: repair the oauth_auth_code splice that broke the nonce table block (missing expires_at, terminator, OWNER ordering). - Integration test: route users to the dynamic backend domain; use the real brig config key settings.setOAuthAuthorizationCodeExpirationTimeSecs.
Adds the guarded cron.schedule migration for the short-lived oauth_auth_code rows (daily sweep; reads already filter on expires_at), mirroring the mls-proposal-refs TTL-cleanup template. Also restores the opening '--' comment line for the oauth_auth_code_pkey constraint block in postgres-schema.sql.
…gs, migration tests)
blackheaven
force-pushed
the
gdifolco/WPB-22966-migration-postgres-oauth-auth-code
branch
from
November 13, 2026 19:02
638f9fb to
90a0296
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


https://wearezeta.atlassian.net/browse/WPB-22966
Checklist
changelog.d