Phase 4c: Intercept non-SSO logins for enforced domains#2798
Phase 4c: Intercept non-SSO logins for enforced domains#2798GregorShear wants to merge 1 commit intomasterfrom
Conversation
0adfd5f to
825b209
Compare
4bf050a to
2b993cd
Compare
7cb615f to
6b4fe9d
Compare
8a8f8f5 to
9479354
Compare
9479354 to
e8081ab
Compare
2a41825 to
78c163b
Compare
| exception when others then | ||
| -- Never block login due to a bug in this hook. | ||
| raise warning 'check_sso_requirement failed for user %: %', target_user_id, SQLERRM; | ||
| return event; |
There was a problem hiding this comment.
Looking for input here - should we block or pass users on exception? do we favor breaking login, or adding a security hole?
either way i'll need help setting up an alert for that warning.
8e55746 to
15109f7
Compare
78c163b to
6fab103
Compare
73fbcc9 to
33c62d9
Compare
33c62d9 to
13db094
Compare
There was a problem hiding this comment.
100% claude generated script for setting up mocksaml in a dev environment. it works on my machine... :)
There was a problem hiding this comment.
will probably remove this skill in favor of the start-with-saml.sh script below
| # Allow/disallow new user signups to your project. | ||
| enable_signup = true | ||
|
|
||
| [auth.hook.custom_access_token] |
There was a problem hiding this comment.
for dev environment - will have to configure this via the supabase dashboard in production
| ); | ||
| end if; | ||
|
|
||
| return event; |
There was a problem hiding this comment.
I've removed the exception handler so exceptions will bubble up to the caller - is this the right approach? is there any specific monitoring we need to set up or are all exceptions like readily visible? (where would i look for these anyway?)
13db094 to
894eba8
Compare
894eba8 to
f800d99
Compare
enforce_ssoboolean column to tenants.customize_access_tokenhook (check_sso_requirement) blocks social login for users with email covered by tenant's SSO domainsauth.users.is_sso_user— SSO users always pass through (important for token refresh).message: 'sso_required:<domain>'— the frontend parses the domain and callssupabase.auth.signInWithSSO({ domain })to redirect the user to their IdP.Users whose email domain does NOT match an enforcing tenant's SSO domain (e.g., contractors with
@gmail.com) are not blocked by the hook. Their grants on enforcing tenants are handled by grant filtering in 4d instead.Activated by
enforce_sso = true. Tenants configure SSO first, then communicate the transition to their users.enforce_ssois flipped on a hard cutoff date.Verify:
sso_required:<domain>enforce_sso = false→ not blocked@gmail.com) → not blocked (grants handled by 4d)is_sso_user = true) with matching domain → not blocked (token refresh works)signInWithSSO({ domain })→ authenticates via IdP → grant migration trigger fires