LoginSignup
3
11

More than 5 years have passed since last update.

WEB APIのCSRF対策の例(ステートレスで)

Posted at

対策例

  • Token APIを作成する
  • Token APIは、JWT(Json Web Token)で電子署名したJSONを返す。
    • JSON項目の例
      • userId:
      • expireDate: 24時間後など
  • 更新APIを呼ぶ前(更新画面表示時など)に、Token API を呼んでJWTを取得する
  • 更新APIをリクエストする際は、AutorizationヘッダにJWTを追加する(クッキーを使用すると対策にならないので注意)

参考

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