Files
accounted/supabase/migrations/20260907100000_bank_connections_oauth_origin.sql
Mattsson c634cf9ae0 fix(banking): return Enable Banking consent callbacks to the initiating brand host (#2371)
* fix(banking): return Enable Banking consent callbacks to the initiating brand host

Enable Banking redirects every consent to the one canonical callback URL
while browser sessions are per host, so a white-label user reached the
callback signed out and was bounced to the unbranded canonical login. The
pending row now records the allowlisted origin the flow started from, and
the callback uses it for the login bounce, the success redirect and the
denial banner. The brand host already holds the session, so its /login
forwards straight back into the callback with cookies; the provider
redirect URI stays canonical, nothing changes in the Enable Banking
console. The shared login redirect helper also stops dragging a callback
that arrived on a registered brand host to the canonical login.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YPom7vRc4jiUKuq3YwjCJz

* fix(banking): reload the PostgREST schema cache after adding oauth_origin

Skeptic finding: every other ADD COLUMN migration ends with the NOTIFY,
and without it PostgREST can reject the new column on connect until its
cache refreshes.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YPom7vRc4jiUKuq3YwjCJz

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-07 14:14:36 +02:00

17 lines
823 B
SQL

-- Record the origin a bank authorization was started from.
--
-- Enable Banking redirects every consent to the one canonical callback URL
-- registered with it, while browser sessions are per host. A user on a
-- white-label domain therefore reaches the callback signed out. The callback
-- reads this column to send the browser back to the initiating host (where
-- the session lives) for the login bounce, the success redirect and the
-- denial banner. Null means "canonical", which is what every pre-existing row
-- and every direct-domain flow gets.
ALTER TABLE public.bank_connections
ADD COLUMN IF NOT EXISTS oauth_origin text;
COMMENT ON COLUMN public.bank_connections.oauth_origin IS
'Allowlist-validated app origin the OAuth flow was started from; null = canonical app URL.';
NOTIFY pgrst, 'reload schema';