LoginSignup
1
0

More than 1 year has passed since last update.

Rails6+devise+omniauth-twitterを使った認証の実装で躓いた。「Not found. Authentication passthru. 」

Last updated at Posted at 2021-06-13

Railsを初めて触る初心者が、過去の記事をあさりながらTwitterAPIを使ったOAuth認証を実装しようとしたときに躓いた話です。

環境

rails6
devise (4.8.0)
omniauth-twitter (1.4.0)

エラーと解決

以下の記事を参考に実装していました。
https://qiita.com/cigalecigales/items/16ce0a9a7e79b9c3974e

Sign in with Twitterリンクを押して、TwitterのOAuth画面に遷移するはずでしたが、ページには遷移せず、「Twitter アカウントによる認証に失敗しました。理由:(Authenticity error)」となりNot found. Authentication passthru.が発生しました。

deviseomniauth-twitterのGithubを読んで原因を探すと....
(参照:https://github.com/heartcombo/devise/wiki/OmniAuth:-Overview)
スクリーンショット 2021-06-13 20.09.12.png
omniauth-rails_csrf_protectionを必ずインストールして下さいとのこと。
omniauthに脆弱性 (https://github.com/omniauth/omniauth/pull/809) があることがわかり、その対策で必要だそうです。2015年から議論されており、2019年には既に解決していたそう。

しっかりドキュメントを読むことは大事。

1
0
0

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
  3. You can use dark theme
What you can do with signing up
1
0