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

Please, add to Readme some important settings. #112

Open
isaichenko opened this issue Feb 2, 2024 · 3 comments
Open

Please, add to Readme some important settings. #112

isaichenko opened this issue Feb 2, 2024 · 3 comments

Comments

@isaichenko
Copy link

For rails 7.1.3

In config/application.rb:
config.action_dispatch.cookies_same_site_protection = lambda { |request|
request.path == '/users/auth/apple' ? :none : :lax
}

In controllers/application_controller.rb:
def verified_request?
controller_name == 'omniauth_callbacks' || super
end

In config/environments/production.rb:
config.assume_ssl = true
config.force_ssl = true

Without these settings the gem did not work for me.
Hope this helps others.

@kschutt
Copy link

kschutt commented Apr 24, 2024

  1. Are the first 2 config changes specifically geared towards disabling CSRF protection on the Apple OAuth flow?
  2. Why is the last config change needed for production?

@34code
Copy link

34code commented Aug 11, 2024

despite doing all the above I'm getting this error in production: ERROR -- omniauth: (apple) Authentication failure! csrf_detected: OmniAuth::Strategies::OAuth2::CallbackError, csrf_detected | CSRF detected

@34code
Copy link

34code commented Aug 11, 2024

I had previously made it work with slightly different code in config/application.rb so my code doesnt have the /users/... part before as my callback url is configured differently..

config.action_dispatch.cookies_same_site_protection = lambda { |request|
      if request.path.starts_with?("/auth/apple")
        :none
      elsif request.path == '/users/auth/apple'
        :none
      else
        :lax
      end
    }

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

3 participants