diff --git a/internal/api/external_figma_test.go b/internal/api/external_figma_test.go index ebc9e61c5..0cfb54e01 100644 --- a/internal/api/external_figma_test.go +++ b/internal/api/external_figma_test.go @@ -128,7 +128,7 @@ func (ts *ExternalTestSuite) TestSignupExternalFigma_PKCE() { var buffer bytes.Buffer require.NoError(ts.T(), json.NewEncoder(&buffer).Encode(map[string]interface{}{ "code_verifier": codeVerifier, - "auth_code": authCode, + "code": authCode, })) req := httptest.NewRequest(http.MethodPost, "http://localhost/token?grant_type=pkce", &buffer) req.Header.Set("Content-Type", "application/json") diff --git a/internal/api/external_fly_test.go b/internal/api/external_fly_test.go index cf357c97b..c2bb01c48 100644 --- a/internal/api/external_fly_test.go +++ b/internal/api/external_fly_test.go @@ -128,7 +128,7 @@ func (ts *ExternalTestSuite) TestSignupExternalFly_PKCE() { var buffer bytes.Buffer require.NoError(ts.T(), json.NewEncoder(&buffer).Encode(map[string]interface{}{ "code_verifier": codeVerifier, - "auth_code": authCode, + "code": authCode, })) req := httptest.NewRequest(http.MethodPost, "http://localhost/token?grant_type=pkce", &buffer) req.Header.Set("Content-Type", "application/json") diff --git a/internal/api/external_github_test.go b/internal/api/external_github_test.go index 7b9d31e89..42b142697 100644 --- a/internal/api/external_github_test.go +++ b/internal/api/external_github_test.go @@ -135,7 +135,7 @@ func (ts *ExternalTestSuite) TestSignupExternalGitHub_PKCE() { var buffer bytes.Buffer require.NoError(ts.T(), json.NewEncoder(&buffer).Encode(map[string]interface{}{ "code_verifier": codeVerifier, - "auth_code": authCode, + "code": authCode, })) req := httptest.NewRequest(http.MethodPost, "http://localhost/token?grant_type=pkce", &buffer) req.Header.Set("Content-Type", "application/json") diff --git a/internal/api/token.go b/internal/api/token.go index 4345d0def..38186d297 100644 --- a/internal/api/token.go +++ b/internal/api/token.go @@ -29,7 +29,7 @@ type PasswordGrantParams struct { // PKCEGrantParams are the parameters the PKCEGrant method accepts type PKCEGrantParams struct { - AuthCode string `json:"auth_code"` + Code string `json:"code"` CodeVerifier string `json:"code_verifier"` } @@ -226,11 +226,11 @@ func (a *API) PKCE(ctx context.Context, w http.ResponseWriter, r *http.Request) return err } - if params.AuthCode == "" || params.CodeVerifier == "" { - return apierrors.NewBadRequestError(apierrors.ErrorCodeValidationFailed, "invalid request: both auth code and code verifier should be non-empty") + if params.Code == "" || params.CodeVerifier == "" { + return apierrors.NewBadRequestError(apierrors.ErrorCodeValidationFailed, "invalid request: both code and code_verifier should be non-empty") } - flowState, err := models.FindFlowStateByAuthCode(db, params.AuthCode) + flowState, err := models.FindFlowStateByAuthCode(db, params.Code) // Sanity check in case user ID was not set properly if models.IsNotFoundError(err) || flowState.UserID == nil { return apierrors.NewNotFoundError(apierrors.ErrorCodeFlowStateNotFound, "invalid flow state, no valid flow state found") diff --git a/internal/api/token_test.go b/internal/api/token_test.go index 356edc0da..8273f9a2e 100644 --- a/internal/api/token_test.go +++ b/internal/api/token_test.go @@ -370,7 +370,7 @@ func (ts *TokenTestSuite) TestTokenPKCEGrantFailure() { var buffer bytes.Buffer require.NoError(ts.T(), json.NewEncoder(&buffer).Encode(map[string]interface{}{ "code_verifier": v.codeVerifier, - "auth_code": v.authCode, + "code": v.authCode, })) req := httptest.NewRequest(http.MethodPost, "http://localhost/token?grant_type=pkce", &buffer) req.Header.Set("Content-Type", "application/json") @@ -614,7 +614,7 @@ func (ts *TokenTestSuite) TestMagicLinkPKCESignIn() { // Extract token and sign in require.NoError(ts.T(), json.NewEncoder(&buffer).Encode(map[string]interface{}{ "code_verifier": codeVerifier, - "auth_code": authCode, + "code": authCode, })) req = httptest.NewRequest(http.MethodPost, "http://localhost/token?grant_type=pkce", &buffer) req.Header.Set("Content-Type", "application/json") diff --git a/openapi.yaml b/openapi.yaml index 30a675efc..b7a062d41 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -99,7 +99,7 @@ paths: refresh_token: 4nYUCw0wZR_DNOTSDbSGMQ grant_type=pkce: value: - auth_code: 009e5066-fc11-4eca-8c8c-6fd82aa263f2 + code: 009e5066-fc11-4eca-8c8c-6fd82aa263f2 code_verifier: ktPNXpR65N6JtgzQA8_5HHtH6PBSAahMNoLKRzQEa0Tzgl.vdV~b6lPk004XOd.4lR0inCde.NoQx5K63xPfzL8o7tJAjXncnhw5Niv9ycQ.QRV9JG.y3VapqbgLfIrJ web3_solana: value: @@ -151,9 +151,10 @@ paths: description: If `provider` is `azure` then you can specify any Azure OIDC issuer string here, which will be used for verification. gotrue_meta_security: $ref: "#/components/schemas/GoTrueSecurity" - auth_code: + code: type: string format: uuid + description: Authorization code from OAuth2 PKCE flow code_verifier: type: string message: