7
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

iOSアプリからRailsへPOSTする際のCSRF対策用トークンについて

Last updated at Posted at 2014-07-04

iOSアプリからRailsのサイトへログインを行う際、iOS側で入力したユーザー名とパスワードをRailsへPOSTとすると、CSRFトークンがリクエストパラメータ中に無いため接続が拒否される。

良いのか分からないけど、事前にCSRFトークンを取得できるようにして回避しようかと検討中。


# ログイン認証とかするコントローラ
class SessionController
 def get_csrf_token
    render text: form_authenticity_token
 end
end

他により良い案があれば、ご教授お願いします。
csrfトークンをむやみに返してよいものか。。。

7
7
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
7
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?