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

Error when callback ? #64

Closed
classicboy opened this issue Nov 24, 2020 · 12 comments
Closed

Error when callback ? #64

classicboy opened this issue Nov 24, 2020 · 12 comments

Comments

@classicboy
Copy link

I am using this gem together with Devise for 'Sign in with Apple' feature from my web. Everything work fine when redirect to Apple Sign in page. But after succesful sign in, a callback to my web and error happen ( in local enviroment ).
I only can fix this error if add protect_from_forgery prepend: true, only: :apple to the top of OmniauthCallbacksController. But I dont think this is the right way to fix it.

image

@pablomarti
Copy link

I am getting exactly the same error.

@pablomarti
Copy link

Hey @classicboy check this out: #54 (comment) and https://github.com/omniauth/omniauth/wiki/Resolving-CVE-2015-9284

@SwannG
Copy link

SwannG commented Dec 23, 2020

Hello everyone, I was getting an "Can't verify CSRF token authenticity" after Apple sign in page.
As said by @pablomarti I added the gem : https://github.com/omniauth/omniauth/wiki/Resolving-CVE-2015-9284 but now I'm getting an "ActionController::InvalidAuthenticityToken" just like you @classicboy. Did you managed to fix your issue ? Any idea on what's going on and how to fix it ?

@esellin
Copy link

esellin commented Dec 24, 2020

See this interesting discussion from the Discourse guys trying to implement Apple SSO on their website.

The trouble is Apple using a POST for the final redirect. i created a dedicated controller in my Rails app to receive this POST request from Apple, on which I specifically disable all CSRF checks, and this controller just redirects to the standard OmniAuth callback URL like this:

    redirect_to "/users/auth/apple/callback?state=#{request.params["state"]}&code=#{request.params["code"]}"

From testing with Apple SSO on the Discourse website, it looks like this is what they are doing.

Hope this helps!

@SwannG
Copy link

SwannG commented Jan 4, 2021

@esellin thanks for the answer !

I finally managed to make it work by adding skip_before_action :verify_authenticity_token, only: :apple at the top of my omniauth_callbacks_controller.rb but after I was getting Can't verify CSRF token authenticity. and to fix it in config/initializers/session_store.rb I removed the domain: ...

@Meat-Chopper
Copy link

Is it possible to implement something like Discourse plugin solution https://github.com/discourse/discourse-apple-auth/blob/40ef076fa744d562ce54f3f30921a1b387e042fb/lib/omniauth_apple.rb#L60 in this gem?

@wilg
Copy link
Contributor

wilg commented Feb 22, 2021

@esellin Your solution worked for me, though I had to also pass through user to get the user name properly. However, once I added Sign In With Apple JS it stopped working and started failing with csrf_detected.

Anybody have ideas?

@rbarrera87
Copy link

Did you solve your issue @wilg?

@wilg
Copy link
Contributor

wilg commented Jun 16, 2022

I think I did get it working but can't look up the solution at this moment.

@rbarrera87
Copy link

No worries @wilg I will keep investigating, the thing is that I am working with a Rails API and the solution from @Meat-Chopper does not work for me. If I find the answer I will post it here.

@nov
Copy link
Collaborator

nov commented Sep 27, 2022

set SameSite=none on your cookie

@salzig
Copy link

salzig commented May 31, 2023

Instead of opening up the session to potential security risks, we may merge #107 and allow the nonce to be stored in its own encypted cookie?

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

9 participants