create account

HiveSnap - Session-Cookies Vs. JWT Authentication - JWT 學習日記 - 004 by nuagnorab

View this thread on: hive.blogpeakd.comecency.com
· @nuagnorab ·
$15.13
HiveSnap - Session-Cookies Vs. JWT Authentication - JWT 學習日記 - 004
剛開始學習使用有關 JWT 的 Authentication。

什麼是 JWT (JSON Web Token)?
[HiveSnap - JWT (JSON Web Token) 學習日記 - 01](https://steemcn.herokuapp.com/hive-180932/@nuagnorab/steemsnap-jwt-json-web-token-01)

Basic session-based Authentication flow。
 [HiveSnap - JWT (JSON Web Token) 學習日記 - 02 - Basic session-based Authentication flow](https://steemcn.herokuapp.com/hive-180932/@nuagnorab/steemsnap-jwt-json-web-token-02-basic-session-based-authentication-flow)

Basic JWT-based Authentication flow。
 [HiveSnap - JWT (JSON Web Token) 學習日記 - 03 - Basic JWT-based Authentication flow](https://steemcn.herokuapp.com/hive-180932/@nuagnorab/steemsnap-jwt-json-web-token-03-basic-jwt-based-authentication-flow)

---

![image.png](https://cdn.steemitimages.com/DQmaYcdmzntDFJqDziSBEcXHaGKWL2wsyRVkqv4x3ytej7F/image.png)
[Source - Ben Awad](https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Do9hT7v0OLJc&psig=AOvVaw3VCBAFGjUEn8w2xZMwJaDm&ust=1594224829381000&source=images&cd=vfe&ved=0CA0QjhxqFwoTCPiP8rrEu-oCFQAAAAAdAAAAABAD)

業界使用 session-cookie 模式已有很長時間了。例如在 Ruby on Rails 盛行的年代。

也因為時間夠長,在實施 Authentication 功能時,可以在線找到許多不同語言的解決方案。基本上不會怕在 Stackoverflow 上找不到需要的提示。

 因此,在前期沒有External Module時在 App 上使用上 JWT-based 這樣的基於 Token 的 Authentication 相比,開發人員更容易傾向使用 session-based。

感謝 NodeJS 的興起。 有許多 Module/Library 為 NodeJs 開發人員提供了一種簡單得多的方法來設置基於 Token 的 Authentication。 如```passport-jwt```。

---

Session-Cookies Vs. JWT Authentication

Scalable 擴展性


在現代Web應用程序中,尤其是在 react & vue 應用程序的興起中,由於 JWT token 存儲在客戶端,因此JWT token-based 的擴展性優於 session-based 的。

Session 使用 server memory 來存儲用戶數據,這在擴展服務器時給服務器增加了更多負擔,並當在有多位用戶同時間一齊訪問該應用程序會帶來許多不便。

---

Security 安全性

雖然只要有連線上網就是被惡意攻擊的可能,但在現時 JWT 使用 ```BASE64```編碼,比起session-cookie 更有防護力。

不過在此也要說清楚,敏感或重要的資料,可以的話就不要在網上傳播了。

---

Cheers!
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 280 others
👎  
properties (23)
authornuagnorab
permlinkhivesnap-session-cookies-vs-jwt-authentication-jwt-004
categoryhive-105017
json_metadata{"app":"peakd/2020.07.1","format":"markdown","tags":["cn","cn-reader","cn-curation","palnet","build-it","neoxian"],"users":["nuagnorab"],"links":["https://steemcn.herokuapp.com/hive-180932/@nuagnorab/steemsnap-jwt-json-web-token-01","https://steemcn.herokuapp.com/hive-180932/@nuagnorab/steemsnap-jwt-json-web-token-02-basic-session-based-authentication-flow","https://steemcn.herokuapp.com/hive-180932/@nuagnorab/steemsnap-jwt-json-web-token-03-basic-jwt-based-authentication-flow","https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Do9hT7v0OLJc&psig=AOvVaw3VCBAFGjUEn8w2xZMwJaDm&ust=1594224829381000&source=images&cd=vfe&ved=0CA0QjhxqFwoTCPiP8rrEu-oCFQAAAAAdAAAAABAD"],"image":["https://cdn.steemitimages.com/DQmaYcdmzntDFJqDziSBEcXHaGKWL2wsyRVkqv4x3ytej7F/image.png"]}
created2020-07-07 16:26:27
last_update2020-07-07 16:26:27
depth0
children0
last_payout2020-07-14 16:26:27
cashout_time1969-12-31 23:59:59
total_payout_value7.656 HBD
curator_payout_value7.471 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,769
author_reputation125,097,310,898,849
root_title"HiveSnap - Session-Cookies Vs. JWT Authentication - JWT 學習日記 - 004"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id98,392,477
net_rshares37,192,105,927,409
author_curate_reward""
vote details (345)