質問編集履歴

3

2017/07/15 23:50

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -17,3 +17,17 @@
17
17
  # 参考
18
18
 
19
19
  https://stackoverflow.com/questions/34817617/should-jwt-be-stored-in-localstorage-or-cookie
20
+
21
+
22
+
23
+ - localStorage is subjected to XSS and generally it's not recommended to store any sensitive information in it.
24
+
25
+
26
+
27
+ - With Cookies we can apply the flag "httpOnly" which mitigates the risk of XSS. However if we are to read the JWT from Cookies on backend, we then are subjected to CSRF.
28
+
29
+
30
+
31
+
32
+
33
+ So based on the above premise - it will be best if we store JWT in Cookies. On every request to server, the JWT will be read from Cookies and added in the Authorization header using Bearer scheme. The server can then verify the JWT in the request header (as opposed to reading it from the cookies).

2

2017/07/15 23:50

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -11,3 +11,9 @@
11
11
  # 補足
12
12
 
13
13
  前提として、ユーザーがログインに成功するとサーバー側から生成されたJWTトークンがクライアント側に送られてくるという仕様を想定しての話となります。そのトークンをクッキーに保存するべきか、もしくは、ローカルストレージに保存すべきかといった質問内容です。よろしくお願いいたします!
14
+
15
+
16
+
17
+ # 参考
18
+
19
+ https://stackoverflow.com/questions/34817617/should-jwt-be-stored-in-localstorage-or-cookie

1

ほそく

2017/07/15 23:45

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -5,3 +5,9 @@
5
5
 
6
6
 
7
7
  クッキーに保存してリクエストヘッダーにクッキーに保存しておいたトークンを入れてリクエストを送信するといったやり方の方がセキュアでしょうか?
8
+
9
+
10
+
11
+ # 補足
12
+
13
+ 前提として、ユーザーがログインに成功するとサーバー側から生成されたJWTトークンがクライアント側に送られてくるという仕様を想定しての話となります。そのトークンをクッキーに保存するべきか、もしくは、ローカルストレージに保存すべきかといった質問内容です。よろしくお願いいたします!