Replies: 4 comments 3 replies
|
Going by the Send Email Hook documentation and GoTrue's behavior on managed Supabase: 1. Does it intercept all email categories? 2. Failure modes & SMTP fallback
3. Safe verification pattern Instead, make the hook insert into a private test table and return success ({}): `sql -- Lock down PostgREST access so live tokens cannot be queried with anon/authenticated keys create or replace function public.hook_send_email_sink(event jsonb) revoke execute on function public.hook_send_email_sink(jsonb) from public, anon, authenticated; This ensures zero real emails are sent, while your tests can query est_auth_outbox using service_role to assert the email fired and grab oken or oken_hash to finish the flow. (Operational note: truncate or delete sink rows when a test cycle completes, as tokens remain valid until expiry.) |
|
The sink pattern above is the correct one; one security point it misses: that table becomes a live-token store. The Two extra lines make it safe: -- Hook function: execution only for the auth admin (as above), never public
revoke execute on function public.hook_send_email_sink(jsonb) from public, anon, authenticated;
grant execute on function public.hook_send_email_sink(jsonb) to supabase_auth_admin;
-- Sink table: no app-role reads; service_role only, for test assertions
alter table public.test_auth_outbox enable row level security;
revoke all on public.test_auth_outbox from anon, authenticated;
grant select, delete on public.test_auth_outbox to service_role;Two operational notes: truncate or delete sink rows when the test cycle ends — tokens in the table stay valid until they expire, so an unattended sink table is an unattended set of credentials. And keep the verification assertion in the sink query (the flow above), not by emailing yourself; that way suppression and flow testing stay independent of each other. |
|
@MsMansiDhruv — the revoke all on public.test_auth_outbox from public;
revoke all on public.test_auth_outbox from anon, authenticated;
grant select, delete on public.test_auth_outbox to service_role; -- already there( |
|
@MsMansiDhruv — good, that's the one that matters in an auth path. One tightening on it worth knowing if you haven't hit it yet:
create or replace function security definer_helper() returns void
language plpgsql
security definer
set search_path = '' -- nothing product-visible can shadow anything
as $$
begin
insert into private.audit_log (...) select ...; -- every reference qualified
end $$;
The trade worth remembering: |
Uh oh!
There was an error while loading. Please reload this page.
We need to prevent unintended authentication and security emails reaching real users during acceptance testing. We are evaluating a PostgreSQL Send Email Hook that rejects delivery. Does it intercept signup, recovery, invitations, enabled security notifications, and other email categories? What happens on hook error, timeout, unavailable database, SMTP fallback, or queued/in-flight messages? How can teams safely verify suppression without sending emails to real recipients while still meaningfully testing signup and recovery flows? Please share official documentation and experience on managed Supabase.
All reactions