-
Notifications
You must be signed in to change notification settings - Fork 499
feat(auth): add OAuth 2.1 authorization consent management API calls #1793
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| client: OAuthAuthorizationClient | ||
| /** User object associated with the authorization */ | ||
| user: { | ||
| /** User ID (UUID) */ | ||
| id: string | ||
| /** User email */ | ||
| email: string | ||
| } | ||
| /** Space-separated list of requested scopes */ | ||
| scope: string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can these values be optional/undefined? I ask because I see them tagged with omitempty but I can't seem to find a case they would be
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point and yeah ideally they should always exists. The context on why we have omitempty is: supabase/auth#2107 (comment)
| if (data.redirect_uri) { | ||
| // Automatically redirect in browser unless skipBrowserRedirect is true | ||
| if (isBrowser() && !options?.skipBrowserRedirect) { | ||
| window.location.assign(data.redirect_uri) | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit on the fence about this: it feels like the default should be that we return the redirect URL to the caller and let them handle the redirect given that these APIs are slightly lower level (as opposed to having some hosted consent page).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Completely get you, wanted to stick with the existing conventions for skipBrowserRedirect
supabase-js/packages/core/auth-js/src/GoTrueClient.ts
Lines 2455 to 2458 in 0d7a77a
| // try to open on the browser | |
| if (isBrowser() && !options.skipBrowserRedirect) { | |
| window.location.assign(url) | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I would expect the SDK to redirect me when calling a method signInWithOAuth but as a user you might find it unexpected to be redirected when calling getAuthorizationDetails (personally I'd expect an object to be returned).
Summary
Adds user-facing OAuth authorization methods to
@supabase/auth-jsfor building consent pages when Supabase Auth acts as an OAuth 2.1 authorization server.Implements the consent flow where users approve/deny OAuth client authorization requests.
New API
Namespace:
auth.oauth.*Three new methods for managing OAuth authorization consent:
Use Case
Enables developers to build custom OAuth consent pages for their Supabase projects when acting as an OAuth 2.1 authorization server. Example flow:
authorization_idin URLgetAuthorizationDetails(authorizationId)to fetch client and scope infoapproveAuthorization()ordenyAuthorization()What's NOT Included
Third-party OAuth client integration (calling
/oauth/authorizeand/oauth/tokenfrom external apps) is intentionally not included in this PR.Rationale:
Third-party integration will be addressed through comprehensive documentation showing how to use standard OAuth client libraries with Supabase Auth endpoints.
Breaking Changes
None. This is a purely additive change with zero breaking changes to existing APIs