-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1590,3 +1590,103 @@ export interface GoTrueAdminOAuthApi { | |
| */ | ||
| regenerateClientSecret(clientId: string): Promise<OAuthClientResponse> | ||
| } | ||
|
|
||
| /** | ||
| * OAuth client details in an authorization request. | ||
| * Only relevant when the OAuth 2.1 server is enabled in Supabase Auth. | ||
| */ | ||
| export type OAuthAuthorizationClient = { | ||
| /** Unique identifier for the OAuth client (UUID) */ | ||
| client_id: string | ||
| /** Human-readable name of the OAuth client */ | ||
| client_name: string | ||
| /** URI of the OAuth client's website */ | ||
| client_uri: string | ||
| /** URI of the OAuth client's logo */ | ||
| logo_uri: string | ||
| } | ||
|
|
||
| /** | ||
| * OAuth authorization details for the consent flow. | ||
| * Only relevant when the OAuth 2.1 server is enabled in Supabase Auth. | ||
| */ | ||
| export type OAuthAuthorizationDetails = { | ||
| /** The authorization ID */ | ||
| authorization_id: string | ||
| /** Redirect URI - present if user already consented (can be used to trigger immediate redirect) */ | ||
| redirect_uri?: string | ||
| /** OAuth client requesting authorization */ | ||
| 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 | ||
|
Comment on lines
+1619
to
+1628
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| } | ||
|
|
||
| /** | ||
| * Response type for getting OAuth authorization details. | ||
| * Only relevant when the OAuth 2.1 server is enabled in Supabase Auth. | ||
| */ | ||
| export type AuthOAuthAuthorizationDetailsResponse = RequestResult<OAuthAuthorizationDetails> | ||
|
|
||
| /** | ||
| * Response type for OAuth consent decision (approve/deny). | ||
| * Only relevant when the OAuth 2.1 server is enabled in Supabase Auth. | ||
| */ | ||
| export type AuthOAuthConsentResponse = RequestResult<{ | ||
| /** URL to redirect the user back to the OAuth client */ | ||
| redirect_url: string | ||
| }> | ||
|
|
||
| /** | ||
| * Contains all OAuth 2.1 authorization server user-facing methods. | ||
| * Only relevant when the OAuth 2.1 server is enabled in Supabase Auth. | ||
| * | ||
| * These methods are used to implement the consent page. | ||
| */ | ||
| export interface AuthOAuthServerApi { | ||
| /** | ||
| * Retrieves details about an OAuth authorization request. | ||
| * Used to display consent information to the user. | ||
| * Only relevant when the OAuth 2.1 server is enabled in Supabase Auth. | ||
| * | ||
| * @param authorizationId - The authorization ID from the authorization request | ||
| * @param options - Optional parameters including skipBrowserRedirect | ||
| * @returns Authorization details including client info and requested scopes | ||
| */ | ||
| getAuthorizationDetails( | ||
| authorizationId: string, | ||
| options?: { skipBrowserRedirect?: boolean } | ||
| ): Promise<AuthOAuthAuthorizationDetailsResponse> | ||
|
|
||
| /** | ||
| * Approves an OAuth authorization request. | ||
| * Only relevant when the OAuth 2.1 server is enabled in Supabase Auth. | ||
| * | ||
| * @param authorizationId - The authorization ID to approve | ||
| * @param options - Optional parameters including skipBrowserRedirect | ||
| * @returns Redirect URL to send the user back to the OAuth client | ||
| */ | ||
| approveAuthorization( | ||
| authorizationId: string, | ||
| options?: { skipBrowserRedirect?: boolean } | ||
| ): Promise<AuthOAuthConsentResponse> | ||
|
|
||
| /** | ||
| * Denies an OAuth authorization request. | ||
| * Only relevant when the OAuth 2.1 server is enabled in Supabase Auth. | ||
| * | ||
| * @param authorizationId - The authorization ID to deny | ||
| * @param options - Optional parameters including skipBrowserRedirect | ||
| * @returns Redirect URL to send the user back to the OAuth client | ||
| */ | ||
| denyAuthorization( | ||
| authorizationId: string, | ||
| options?: { skipBrowserRedirect?: boolean } | ||
| ): Promise<AuthOAuthConsentResponse> | ||
| } | ||
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).
Uh oh!
There was an error while loading. Please reload this 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
skipBrowserRedirectsupabase-js/packages/core/auth-js/src/GoTrueClient.ts
Lines 2455 to 2458 in 0d7a77a
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
signInWithOAuthbut as a user you might find it unexpected to be redirected when callinggetAuthorizationDetails(personally I'd expect an object to be returned).