Skip to content
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

refactor(core): refactor oidc error response query param #6525

Merged
merged 1 commit into from
Aug 28, 2024

Conversation

simeng-li
Copy link
Contributor

@simeng-li simeng-li commented Aug 27, 2024

Summary

Introduce a new parse_error query parameter flag. The value of parse_error can only be false.

By default, Logto returns the parsed error code and error description in all the RequestError error responses. This is to ensure the error responses are consistent and easy to understand.

However, when integrating Logto with Google OAuth, the error response body containing code will be rejected by Google. code is considered a reserved OIDC key, and can't be used as the error code key in the error response body.

To work around this, we add a new parse_error query parameter flag. When parsing the OIDC error body, if the parse_error is set to false, only oidc error body will be returned.

example:

curl -X POST "http://localhost:3001/oidc/token?parse_error=false"
{
  "error": "invalid_grant",
  "error_description": "Invalid value for parameter 'code': 'invalid_code'."
}

Testing

Test locally

image

Checklist

  • .changeset
  • unit tests
  • integration tests
  • necessary TSDoc comments

refactor oidc error reponse query param
@simeng-li simeng-li requested review from a team August 27, 2024 11:06
@github-actions github-actions bot added the enhancement Make it better label Aug 27, 2024
Copy link

COMPARE TO master

Total Size Diff 📉 -127 Bytes

Diff by File
Name Diff
.changeset/tiny-fishes-bake.md 📉 -32 Bytes
packages/core/src/middleware/koa-oidc-error-handler.ts 📉 -95 Bytes

@simeng-li simeng-li merged commit 8beb758 into master Aug 28, 2024
38 checks passed
@simeng-li simeng-li deleted the simeng-error-response-query-key branch August 28, 2024 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Make it better size/s
Development

Successfully merging this pull request may close these issues.

2 participants