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

Apple Sign In with Rails and Kamal raises ActionController::InvalidAuthenticityToken error #67

Open
joaomarceloods opened this issue Nov 13, 2024 · 1 comment

Comments

@joaomarceloods
Copy link

Context: Apple sign-in with omniauth-apple worked fine until a week ago when the company moved the app to Kamal. We started getting this error:

ActionController::InvalidAuthenticityToken (HTTP Origin header (https://appleid.apple.com/) didn’t match request.base_url (https://www.myapp.com/))

I found a suggestion to forward the X-Forwarded-Proto and X-Forwarded-Ssl headers. The X-Forwarded-Proto is configurable in Kamal but it didn't fix the issue. X-Forwarded-Ssl doesn't seem to be configurable.

I also found a suggestion to set the Origin header to your own domain, but I don't think that's configurable with Kamal.

Is there another way to configure these headers? Any help fixing this issue is appreciated too.

@3v0k4
Copy link

3v0k4 commented Nov 14, 2024

It looks like Apple performs a POST to the redirect uri instead of the usual OAuth flow. I assume that the error you see happens at that stage since the POST triggers the CSRF check.

There are some interesting links in this issue with all sorts of solutions (watch out for the insecure hacks!).

I'd speculate that in the process of moving to Kamal, some other workarounds that your company had in place were removed.

Issue in omniauth-apple: nhosoya/omniauth-apple#114

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants