fix: ignore CSRF middleware on Apple OIDC callback #3643
Merged
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.
This change ensures that CSRF middleware is ignored on
/self-service/oidc/callback/apple
(previously it was only exempted).After a user authenticates on Apple, Apple redirects the user back to Kratos using a form POST. Since this is a POST, the CSRF cookie is not passed (since the cookie's SameSite attribute is set to Lax). This causes Kratos to add a different CSRF cookie.
While this doesn't break the registration flow itself, it causes a problem if we want to send the user back to the original login flow. In some cases, we may want to do this to cancel the registration and allow the user to log in with different credentials. It may be important to maintain the existing login flow in case the login originated from an OAuth2 client via Hydra instead of simply creating a new login flow.
Related issue(s)
Not reported separately. Steps to reproduce:
This issue does not impact other OIDC providers such as Google or Facebook since they do not rely on form POST when redirecting to the Kratos callback endpoint.
Checklist
introduces a new feature.
contributing code guidelines.
vulnerability. If this pull request addresses a security vulnerability, I
confirm that I got the approval (please contact
[email protected]) from the maintainers to push
the changes.
works.
Further Comments