feat(gotrue): add user-facing OAuth 2.1 server authorization API#1483
Open
gourabsingha1 wants to merge 2 commits into
Open
feat(gotrue): add user-facing OAuth 2.1 server authorization API#1483gourabsingha1 wants to merge 2 commits into
gourabsingha1 wants to merge 2 commits into
Conversation
Adds the user-facing OAuth 2.1 server authorization consent flow methods:
- `getAuthorizationDetails(authorizationId)` (GET `/oauth/authorizations/{id}`)
- `approveAuthorization(authorizationId, {skipBrowserRedirect})` (POST `/oauth/authorizations/{id}/consent` with action: 'approve')
- `denyAuthorization(authorizationId, {skipBrowserRedirect})` (POST `/oauth/authorizations/{id}/consent` with action: 'deny')
These are exposed on GoTrueClient via `client.oauthServer`. Also added a comprehensive test suite in `gotrue_oauth_server_api_test.dart`.
Closes supabase#1475
Fixes DCM lint warning avoid-unused-local-variable and ensures dart format passes on CI.
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.
Description
This PR implements the user-facing OAuth 2.1 server authorization consent flow methods on the
GoTrueClientunder the namespaceoauthServer(viaclient.oauthServer).These methods are useful when your Supabase project acts as an OAuth 2.1 server and you are building a custom consent/authorization screen.
The following user-facing consent endpoints are exposed:
client.oauthServer.getAuthorizationDetails(authorizationId): Retrieve client details and requested scopes for a pending authorization request.client.oauthServer.approveAuthorization(authorizationId, {skipBrowserRedirect}): Approve the authorization request.client.oauthServer.denyAuthorization(authorizationId, {skipBrowserRedirect}): Deny the authorization request.Suggested Solution Context
Addresses: #1475
Test Plan
Added a comprehensive suite of unit tests in
packages/gotrue/test/src/gotrue_oauth_server_api_test.dartthat validates request paths, HTTP methods, body payloads, query parameters, and JSON response deserialization for all three methods. All tests pass successfully.