Repository navigation
fix(oauth-server): inherit approving session's AAL in OAuth tokens - #2869
rudrakshsisodia wants to merge 1 commit into
Conversation
Tokens from /oauth/token were always aal1, even when consent was given from an MFA-verified session. Record the approving session on the authorization and copy its AAL, factor and AMR claims into the new OAuth session. Fixes supabase#2838
| if err != nil && !models.IsNotFoundError(err) { | ||
| return apierrors.NewInternalServerError("Error finding approving session").WithInternalError(err) | ||
| } | ||
| grantParams.InheritFrom = approvingSession |
There was a problem hiding this comment.
If the approving session was deleted before the code exchange (user signed out, and the FK is on delete set null), this falls through with InheritFrom nil and the token gets the default AAL. So someone who consented with MFA ends up with an aal1 token. Should the exchange fail instead when SessionID was set but the session's gone?
|
We use Supabase's OAuth 2.1 server as the authorization server for a remote MCP server, and without this every OAuth token is On the open edge case: I'd fail the code exchange when |
|
Thanks! This addresses our production MCP blocker in #2838. Our consent flow already requires AAL2 before resolving or approving authorization, including auto-approval, and our MCP server rejects tokens below AAL2. Inheriting the approving session’s AAL/AMR would let us retain that enforcement. On the missing approving-session case, we favor rejecting the code exchange rather than silently issuing AAL1. Could the tests also cover refresh-token exchange preserving AAL2 and the inherited AMR? We’d be happy to validate the hosted rollout against our MCP flow. |
|
+1 from Hatz AI. We use the OAuth 2.1 server for our Microsoft Excel add-in. Our consent flow already requires aal2, but the exchanged token is always aal1, so MFA users are asked for a second TOTP in the add-in. Inheriting the approving session's AAL/AMR at code exchange, as this PR does, would fix it for us. We are happy to test a release on a hosted project. |
|
I ran the full OAuth flow against real builds of this PR, its base and current master. The goal was to check the fix end to end, plus the two edge cases raised above (approving session gone, and when the AAL is read). Setup: four images built from full SHAs (each one's
Behaviour changes, beyond the fix itself:
Not tested: WebAuthn/phone factors, SSO/SAML amr, the custom access token hook, OrioleDB, or the Go test suite (including the new |
|
Any updates on this? We are currently gated on adopting supabase fully for oauth |
|
This also broke our MCP flows, so it would be very nice to get this fixed as soon as possible |
Fixes #2838
Tokens issued by
/oauth/tokenwere alwaysaal1, even when the user consented from an MFA-verified (aal2) session, so resource servers requiringaal2could not accept any OAuth token.Change
oauth_authorizations.session_id(manual consent and auto-approve).on delete set null), behaviour is unchanged:aal1.Test
TestAuthCodeGrantInheritsApprovingSessionAAL: fails onmaster(aal1), passes with this change.