Repository navigation
fix: restrict OAuth client access tokens to OAuth endpoints - #2898
Merged
Merged
Conversation
Access tokens issued by the OAuth 2.1 server are now only accepted on endpoints intended for OAuth clients (/oauth/userinfo). Other authenticated endpoints and admin endpoints return 403 for these tokens. OAuth clients should use /oauth/userinfo to read user information instead of GET /user.
cemalkilic
force-pushed
the
cemal/scope-oauth-tokens-to-oauth-endpoint
branch
from
November 3, 2026 16:39
e642e6d to
4a54228
Compare
hf
approved these changes
Nov 3, 2026
cstockton
pushed a commit
that referenced
this pull request
Nov 13, 2026
…locked (#2926) ## What #2898 restricted OAuth client access tokens to OAuth endpoints. That also blocked `GET /user`, which breaks existing projects that read the user with these tokens (e.g. `supabase.auth.getUser()`). This PR **temporarily** allows OAuth client access tokens on `GET /user` only. All modifying actions still reject them with `403 no_authorization`: - `PUT /user` - `/user/identities/*`, `/user/oauth/grants` - `/factors/*`, `/passkeys/*` - `/logout`, `/reauthenticate` - `/admin/*`, `/invite` ## How The `/user` group used to apply `requireAuthentication` to every route in it. Now each route sets its own middleware: `GET /user` uses `requireAuthenticationAllowOAuthClient`, and every other `/user` route keeps `requireAuthentication`. A comment on the route group says that new `/user` routes must add `requireAuthentication`. ## Note: this is temporary `GET /user` returns `app_metadata`, the full `user_metadata`, identities and factors. That is more than the scopes an OAuth client is granted. We are reopening it for now so existing projects don't break. We will revisit this soon and reject OAuth client tokens on `/user` entirely. OAuth clients should move to `GET /oauth/userinfo`. ## Tests `TestOAuthClientTokenRouteAccess` now covers: - `GET /user` and `/oauth/userinfo` return 200 with an OAuth client token. - The modifying endpoints above return 403 with an OAuth client token. - A rejected `PUT /user` leaves the user unchanged.
artex-x
added a commit
to artex-x/daggerheart-loot
that referenced
this pull request
Nov 14, 2026
…e database A reader can now allow an app or AI assistant on the consent page /connect/<id> and see and disconnect it in «Подключённые приложения» on the account page. A connected app's token works at PostgREST directly, so the migration 20261113120000_api_client_guard bounds it there: a pre-request guard refuses every table and function outside the account API's list and a token whose session a revoke ended, and restrictive policies cover user_prefs, print_sets and Storage updates and deletes. The app's own token and anon are unchanged. supabase/config.toml now owns [auth.oauth_server], so config:push is the switch. Production stays off until Supabase's fix (supabase/auth#2898) is deployed and probes P1-P4 pass on the hosted project; the consent and privacy texts state what is true with that fix. Task: ai-mcp (B5a)
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.
What
Access tokens issued by the OAuth 2.1 server (sessions with
oauth_client_idset) are now only accepted on endpoints intended for OAuth clients. Today that's onlyGET /oauth/userinfo.requireAuthenticationrejects OAuth client tokens with403 no_authorization. Every route that uses it is covered by default, including new routes added later.requireAuthenticationAllowOAuthClientis the explicit opt-in, used only by/oauth/userinfo.requireAdminCredentialsalso rejects OAuth client tokens. This covers/admin/*,/inviteand the admin captcha bypass, even if the user's role is inJWT.AdminRoles.session.oauth_client_idfrom the DB rather than theclient_idclaim, because a custom access token hook can rewrite claims.Behavior change
This only affects access tokens issued to OAuth clients. Regular user sessions are unchanged.
OAuth client access tokens were previously accepted on the end-user account endpoints. They now get
403 no_authorizationon:GET /userandPUT /user/factors/*/passkeys/*/user/identities/*/user/oauth/grants/oauth/authorizations/*/reauthenticate/logout/admin/*,/inviteMigration for OAuth clients: clients that read the user with an OAuth access token (e.g.
GET /user/supabase.auth.getUser()) should useGET /oauth/userinfoinstead. It returns claims based on the granted scopes:sub, alwaysemail,email_verifiedwith theemailscopename,picture,preferred_usernamewith theprofilescopephonescopeapp_metadata, the fulluser_metadata, identities and factors are no longer available to OAuth clients. This is intentional: they go beyond what the user consented to.