Custom Omniauth 'Ошибка аутентификации!csrf_detected» - PullRequest
0 голосов
/ 23 декабря 2018

Я пытаюсь создать собственный Omniauth для Smartrecruiters API OAuth 2.0

omniauth.rb

module OmniAuth
  module Strategies   
   class SmartRecruiters < OmniAuth::Strategies::OAuth2
    option :name, 'smart_recruiters'
    option :client_options, {
      site: 'https://www.smartrecruiters.com',
      authorize_url: '/identity/oauth/allow',
    }

    def request_phase
     super
    end

    def authorize_params
      super.tap do |params|
        %w[scope client_options].each do |v|
          if request.params[v]
            params[v.to_sym] = request.params[v]
          end
        end
      end
    end
  end
end

и вне модуля (в одном файле):

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :smart_recruiters, {client_id}, {client_secret},
           scope: {scope},
           :setup => lambda {|env|
             site = "https://www.smartrecruiters.com/identity/oauth/allow"
             env['omniauth.strategy'].options[:client_options].site = site
           }
end

rout.rb

 match 'auth/:provider/callback', to: 'integrations#create', via: [:get,:post]

Я получаю этот ответ:

ERROR (smart_recruiters) Authentication failure! csrf_detected: OmniAuth::Strategies::OAuth2::CallbackError, csrf_detected | CSRF detected
ERROR (smart_recruiters) Authentication failure! invalid_credentials: OmniAuth::Strategies::OAuth2::CallbackError, csrf_detected | CSRF detected
FATAL

Я читал об отключении CSRF с помощью: skip_before_action: verify_authenticity_token, только:: создать в моем контроллере, но это ничего не изменило.

Я использую Rails 4.2.8 и Ruby 2.4.5p335.

Есть предложения?

Спасибо

...