LoginSignup
28

More than 3 years have passed since last update.

posted at

updated at

[Rails]gem "OmniAuth" の脆弱性対策

gem "OmniAuth" で脆弱性が指摘されていたとのこと。
https://github.com/omniauth/omniauth/pull/809

それに対応するgemが発表されているとのこと。
https://github.com/cookpad/omniauth-rails_csrf_protection

対応gemの使い方は以下。

Gemfile
gem "omniauth-rails_csrf_protection"

上記追記してbundle install。

ビューファイル
= link_to "/auth/google_oauth2", method: :post

SNS認証へのlink_toに、method: :postを追記する。
ルーティングは変更する必要ない。元がgetならgetのままでOK。
これで問題なく認証できればOK。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
28