剛開始學習使用有關 JWT 的 Authentication。 前天談到什麼是 JWT (JSON Web Token)? [SteemSnap - JWT (JSON Web Token) 學習日記 - 01](https://steemcn.herokuapp.com/hive-180932/@nuagnorab/steemsnap-jwt-json-web-token-01) 昨天簡介一下 Basic session-based Authentication flow。 [SteemSnap - 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. 我是跟據使用上 ```passport-jwt``` 簡化後的 flow.  1. 用戶使用 credentials 登錄 2. 後端服務器驗證 credentials,屴功後簽署```JWT```,然後將該```JWT```發送回用戶的客户端。 3. 用戶將通過本地存儲將JWT存儲在客户端瀏覽器中。 4. 對於每個請求,客戶端(通常是 React / vue 應用程序)會將存儲在```localStorage```中的```JWT```添加到```Authorization HTTP header``` 中(類似於 ```session``` 存儲在Cookie header 中的方式) 5. 對於每個請求,後端應用程序將運行 ```passport.authenticate()```中間件,該中間件將從```Authorization HTTP header```中提取```JWT```,使用公共密鑰進行驗證,允許或禁止用戶訪問路線或進行API調用 。 --- 以上就是簡單的 JWT-based Authentication flow 了。 下次會比較一下 Session-based 和 JWT-based 的。 Cheers!
author | nuagnorab |
---|---|
permlink | steemsnap-basic-jwt-based-authentication-flow-jwt-003 |
category | hive-105017 |
json_metadata | {"app":"peakd/2020.07.1","format":"markdown","image":["https://hackernoon.com/photos/pazJZnCJTqSZxQS4tltZo4Gatbo1-fo8h3yl1"],"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"],"tags":["cn","cn-reader","cn-curation","palnet","neoxian","build-it"],"users":["nuagnorab"]} |
created | 2020-07-06 17:06:03 |
last_update | 2020-07-07 16:24:33 |
depth | 0 |
children | 0 |
last_payout | 2020-07-13 17:06:03 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 2.256 HBD |
curator_payout_value | 2.218 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 1,113 |
author_reputation | 125,097,310,898,849 |
root_title | "HiveSnap - Basic JWT-based Authentication flow - JWT 學習日記 - 003" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 98,375,596 |
net_rshares | 12,252,601,263,851 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
wongshiying | 0 | 8,581,295,604 | 100% | ||
lemooljiang | 0 | 296,804,032,847 | 48% | ||
tensaix2j | 0 | 4,272,346,523 | 100% | ||
skysunny | 0 | 56,911,884 | 48% | ||
cnfund | 0 | 102,248,410,868 | 100% | ||
justyy | 0 | 890,316,816,352 | 100% | ||
btshuang | 0 | 1,346,615,693 | 100% | ||
devilwsy | 0 | 3,442,116,128 | 100% | ||
janiceting | 0 | 3,445,507,329 | 100% | ||
timool | 0 | 83,886,379 | 48% | ||
lucknie | 0 | 10,901,196,437 | 48% | ||
dumping | 0 | 1,080,129,166 | 48% | ||
htliao | 0 | 7,170,590,087 | 10% | ||
susanlo | 0 | 12,800,708,348 | 70% | ||
cryptoemperor | 0 | 7,940,896,229 | 20% | ||
mys | 0 | 34,409,801,274 | 10% | ||
guyverckw | 0 | 112,912,825,400 | 60% | ||
nanosesame | 0 | 220,128,182,177 | 80% | ||
cpyjeffrey | 0 | 6,868,827,223 | 100% | ||
john.liao | 0 | 511,471,068 | 100% | ||
yvonnetse | 0 | 15,064,900,080 | 20% | ||
kenchung | 0 | 2,894,933,363 | 100% | ||
pakyeechan | 0 | 4,269,650,961 | 50% | ||
jeffreytong | 0 | 2,608,548,842 | 100% | ||
johnliao | 0 | 1,782,068,285 | 100% | ||
helloworld123 | 0 | 916,531,044 | 100% | ||
nuagnorab | 0 | 401,162,689,242 | 100% | ||
kitcat | 0 | 207,635,027,910 | 100% | ||
victorier | 0 | 65,307,377,403 | 40% | ||
linuslee0216 | 0 | 64,200,418,997 | 100% | ||
wilkinshui | 0 | 139,468,946,825 | 100% | ||
carobetc | 0 | 4,222,122,373 | 100% | ||
thomaskikansha | 0 | 17,592,283,280 | 100% | ||
chingyi | 0 | 4,636,339,982 | 100% | ||
mrjt | 0 | 590,459,559 | 100% | ||
aaronli | 0 | 127,595,013,741 | 100% | ||
marylaw | 0 | 2,975,741,254 | 70% | ||
jenthedreamer | 0 | 1,716,233,004 | 100% | ||
shenchensucc | 0 | 55,177,395,788 | 100% | ||
pyc1512 | 0 | 32,561,480 | 100% | ||
vincentttw | 0 | 132,323,352 | 100% | ||
krischy | 0 | 25,378,614,931 | 60% | ||
claratze | 0 | 0 | 100% | ||
jacklcp | 0 | 637,907,851 | 100% | ||
biuiam | 0 | 4,147,020,387 | 100% | ||
whd | 0 | 13,370,322,105 | 10% | ||
kristytyxd | 0 | 1,097,696,495 | 100% | ||
bobowyeahxd | 0 | 266,030,760 | 100% | ||
colinct | 0 | 977,118,507 | 100% | ||
davidmendel | 0 | 1,518,553,293 | 80% | ||
rafalski | 0 | 1,239,839,492 | 10% | ||
mrpointp | 0 | 74,376,087,441 | 100% | ||
mcw | 0 | 1,763,749,019 | 100% | ||
mygod | 0 | 1,336,592,592 | 100% | ||
yuwineryyuvia | 0 | 12,575,156,937 | 100% | ||
boooster | 0 | 16,030,932 | 100% | ||
eason1117 | 0 | 0 | 100% | ||
votebooster | 0 | 0 | 100% | ||
shirlam | 0 | 50,149,130,986 | 100% | ||
everrich | 0 | 7,450,380,499 | 80% | ||
mellissaying | 0 | 230,585,777 | 100% | ||
syh7758520 | 0 | 26,314,976,714 | 100% | ||
kona | 0 | 15,520,423,320 | 50% | ||
diaohuijun | 0 | 6,820,177,556 | 100% | ||
nicolemoker | 0 | 77,128,379,121 | 100% | ||
windtalker | 0 | 838,552,769 | 100% | ||
interactive | 0 | 1,006,179,581 | 20% | ||
aafeng | 0 | 372,405,713,544 | 100% | ||
john811 | 0 | 5,056,842,316 | 100% | ||
spaminator | 0 | -12,294,296,322 | -0.5% | ||
mrspointm | 0 | 89,970,694,485 | 100% | ||
liumei | 0 | 12,419,776,354 | 100% | ||
yhhhhhhhhh | 0 | 2,044,134,835 | 100% | ||
deskart | 0 | 2,257,521,401 | 100% | ||
waiyee422 | 0 | 9,088,092,929 | 100% | ||
fbslo | 0 | 3,852,040,540 | 5% | ||
sportyfree | 0 | 2,571,316,731 | 100% | ||
arronli | 0 | 81,468,020 | 100% | ||
goodboyphilip | 0 | 74,029,750,941 | 100% | ||
rosatravels | 0 | 616,502,321,093 | 100% | ||
superbing | 0 | 570,855,417 | 90% | ||
connieleung | 0 | 464,450,169 | 100% | ||
minloulou | 0 | 39,721,855,109 | 100% | ||
jsquare | 0 | 575,818,209,819 | 38% | ||
vincentyip | 0 | 376,824,610 | 100% | ||
gladyslui | 0 | 15,051,831,338 | 100% | ||
metten | 0 | 5,740,397,792 | 48% | ||
jychbetter | 0 | 8,934,585,256 | 100% | ||
winniex | 0 | 74,380,634,228 | 100% | ||
kawing | 0 | 0 | 100% | ||
jianan | 0 | 3,389,640,099 | 100% | ||
cn-book | 0 | 623,283,750 | 48% | ||
sosoo | 0 | 1,921,602,374 | 100% | ||
nuv | 0 | 1,667,899,503 | 100% | ||
terencetze | 0 | 0 | 100% | ||
windowglass | 0 | 4,227,033,083 | 100% | ||
zmx | 0 | 12,938,000,927 | 100% | ||
cosetteee | 0 | 1,303,056,680 | 100% | ||
nileelily | 0 | 6,255,100,830 | 100% | ||
michelleluilui | 0 | 10,230,299,035 | 100% | ||
stephenma26 | 0 | 0 | 100% | ||
jacktan | 0 | 2,963,733,550 | 50% | ||
cn-movie | 0 | 46,917,724 | 48% | ||
angelina6688 | 0 | 4,505,628,698 | 100% | ||
vivia | 0 | 1,828,000,000 | 48% | ||
hkfund | 0 | 1,511,457,658,182 | 100% | ||
cheva | 0 | 20,323,253,465 | 100% | ||
hkupvotebot | 0 | 1,824,542,660 | 50% | ||
fun2learn | 0 | 5,312,837,616 | 3% | ||
maiyude | 0 | 3,320,198,794 | 100% | ||
xiaoli | 0 | 153,739,602 | 48% | ||
wilhb81 | 0 | 388,737,969,263 | 100% | ||
emmali | 0 | 18,440,184,972 | 100% | ||
youandme | 0 | 938,347,494 | 100% | ||
kirato | 0 | 168,792,316,616 | 100% | ||
sweetdisaster | 0 | 1,273,974,935 | 100% | ||
nostalgic1212 | 0 | 87,465,404,124 | 100% | ||
shentrading | 0 | 28,723,449,688 | 100% | ||
also.einstein | 0 | 7,753,311,106 | 100% | ||
g9g | 0 | 19,106,310,548 | 100% | ||
fishbb | 0 | 1,998,962,995 | 50% | ||
ericet | 0 | 69,343,594,634 | 100% | ||
beleg | 0 | 4,581,783,287 | 10% | ||
aellly | 0 | 194,607,593,970 | 100% | ||
huangzuomin | 0 | 13,398,486,165 | 100% | ||
liewsc | 0 | 2,986,072,182 | 50% | ||
tanzy | 0 | 1,415,462,268 | 50% | ||
herstory | 0 | 9,647,381,166 | 100% | ||
fishdd | 0 | 1,950,713,081 | 50% | ||
andrewma | 0 | 23,278,499,684 | 100% | ||
softmetal | 0 | 11,343,530,587 | 100% | ||
eviacha | 0 | 548,853,546 | 100% | ||
xiaoliang | 0 | 92,469,561,262 | 100% | ||
i-d | 0 | 765,837,635,425 | 100% | ||
honoru | 0 | 435,829,464,861 | 100% | ||
hmayak | 0 | 24,060,489,656 | 100% | ||
springfall | 0 | 3,519,040,348 | 100% | ||
fishlucy | 0 | 13,922,455,514 | 50% | ||
hkphotography | 0 | 2,895,278,020 | 100% | ||
pgr | 0 | 800,063,354 | 50% | ||
ronbong | 0 | 2,996,370,470 | 100% | ||
robertyan | 0 | 16,743,786,994 | 100% | ||
xiaoyuanwmm | 0 | 4,782,448,916 | 100% | ||
kidsreturn | 0 | 5,264,845,721 | 100% | ||
tydebbie | 0 | 7,819,759,403 | 50% | ||
moneybaby | 0 | 806,863,184 | 2.5% | ||
ybeyond | 0 | 4,686,884,292 | 100% | ||
team-cn | 0 | 309,989,962,274 | 100% | ||
hardmetal | 0 | 2,826,535,991 | 100% | ||
coder-bts | 0 | 9,277,230,781 | 100% | ||
wanggang | 0 | 23,677,601,834 | 20% | ||
chick-fil-a | 0 | 3,438,090,073 | 100% | ||
redlobster | 0 | 3,443,438,523 | 100% | ||
fiveguys | 0 | 1,893,490,964 | 100% | ||
marcoy2j | 0 | 3,026,874,775 | 100% | ||
tiffany4ever | 0 | 6,672,001,054 | 100% | ||
bonefish | 0 | 3,424,288,737 | 100% | ||
chilis | 0 | 3,426,592,129 | 100% | ||
olive-garden | 0 | 1,828,083,124 | 100% | ||
zhuanzhibufu | 0 | 2,807,516,307 | 100% | ||
shine.wong | 0 | 3,523,169,742 | 100% | ||
shuxuan | 0 | 3,484,985,208 | 100% | ||
zongli | 0 | 2,098,666,941 | 100% | ||
zhuxi | 0 | 2,803,419,534 | 100% | ||
julian2013 | 0 | 102,536,344,717 | 100% | ||
melaniewang | 0 | 16,660,460,959 | 100% | ||
teamcn-news | 0 | 1,833,118,290 | 100% | ||
wenxuecity | 0 | 2,554,459,096 | 100% | ||
mitbbs | 0 | 3,438,612,520 | 100% | ||
gorbisan | 0 | 9,643,629,673 | 5% | ||
artsymelanie | 0 | 53,880,237,175 | 100% | ||
isaandrich | 0 | 10,456,420,155 | 75% | ||
slientstorm | 0 | 9,926,066,902 | 100% | ||
laissez-faire | 0 | 17,540,943 | 100% | ||
pet.society | 0 | 171,467,509,473 | 100% | ||
canna-collective | 0 | 74,656,904,545 | 30% | ||
minminlou | 0 | 1,400,527,797 | 75% | ||
annepink | 0 | 161,312,982,929 | 100% | ||
block-power | 0 | 153,324,511,628 | 100% | ||
cherryzz | 0 | 312,638,026,293 | 100% | ||
photo-baby | 0 | 151,928,709 | 100% | ||
jamebanfield | 0 | 64,268,110 | 100% | ||
conada | 0 | 66,929,854 | 100% | ||
overthewall | 0 | 24,151,177 | 100% | ||
kawaiv | 0 | 0 | 100% | ||
alexstand | 0 | 0 | 100% | ||
ali-oli | 0 | 151,907,880 | 100% | ||
teamcn-shop | 0 | 29,333,368,550 | 100% | ||
yanyanbebe | 0 | 10,176,026,339 | 100% | ||
vkwong | 0 | 270,053,956 | 100% | ||
bimance | 0 | 111,008,387 | 100% | ||
kelvinzhang | 0 | 5,589,487,234 | 100% | ||
starrouge | 0 | 1,048,492,524 | 50% | ||
wherein | 0 | 23,902,806,900 | 3% | ||
catarafa | 0 | 1,947,764,378 | 100% | ||
zerofive | 0 | 903,811,116 | 50% | ||
cryptoast | 0 | 86,605,440 | 20% | ||
melodyzhou | 0 | 1,172,509,525 | 100% | ||
honey00 | 0 | 706,760,021 | 100% | ||
cryptoast.bounty | 0 | 0 | 100% | ||
rafaeleff15 | 0 | 1,791,893,128 | 100% | ||
ahua | 0 | 1,772,653,441 | 100% | ||
morningshine | 0 | 147,120,974,191 | 100% | ||
gainsomeweight | 0 | 0 | 100% | ||
cnstm | 0 | 8,343,338,300 | 3% | ||
steemitportugal | 0 | 1,172,614,641 | 1% | ||
cn-activity | 0 | 7,328,120,380 | 100% | ||
gear.nsnow | 0 | 596,637,099 | 50% | ||
davidchen | 0 | 70,678,135,664 | 100% | ||
moneybabe | 0 | 329,359,414 | 100% | ||
mia-cc | 0 | 6,424,330,203 | 50% | ||
cecilian | 0 | 7,578,020,458 | 100% | ||
devyleona | 0 | 29,709,093,694 | 100% | ||
yanhan | 0 | 39,190,468,674 | 100% | ||
foodiecouple | 0 | 6,271,365,383 | 100% | ||
m18207319997 | 0 | 13,062,973,949 | 100% | ||
lovelemon | 0 | 14,512,452,719 | 100% | ||
theinspiration | 0 | 559,859,875 | 100% | ||
epic4chris | 0 | 570,509,710 | 100% | ||
cn-hello | 0 | 2,918,424,201 | 100% | ||
mylord1992 | 0 | 7,728,909,290 | 100% | ||
icecoffee | 0 | 893,084,893 | 100% | ||
candy.tang | 0 | 12,432,854,018 | 100% | ||
kgame | 0 | 3,517,650,934 | 100% | ||
hertz300 | 0 | 49,334,538,516 | 100% | ||
koei | 0 | 2,454,811,758 | 100% | ||
we-are-palcoin | 0 | 1,401,970 | 12% | ||
jimhawkins | 0 | 0 | 1% | ||
nympheas | 0 | 17,722,773,715 | 80% | ||
aaronli.sct | 0 | 731,584,481 | 10% | ||
steem-drivers | 0 | 2,091,020,868 | 100% | ||
sumd | 0 | 794,427,837 | 100% | ||
xiaoq.sports | 0 | 5,149,495,865 | 100% | ||
hykwf678233 | 0 | 35,602,947,767 | 100% | ||
atyh | 0 | 6,363,250,561 | 100% | ||
thranax | 0 | 3,381,168,286 | 3% | ||
ericetchen | 0 | 1,872,016,389 | 100% | ||
stevewu | 0 | 4,972,456,172 | 100% | ||
kristinasiu | 0 | 1,897,305,264 | 100% | ||
liberatehongkong | 0 | 290,347,253 | 100% | ||
moleah | 0 | 16,523,657,141 | 100% | ||
trevorlp97 | 0 | 10,908,413,985 | 100% | ||
trevormomo | 0 | 2,215,865,201 | 100% | ||
annzhao | 0 | 15,129,313,270 | 100% | ||
cherrylp147 | 0 | 728,726,780 | 100% | ||
tonimontana.neo | 0 | 0 | 0.47% | ||
cn-trail | 0 | 764,248,860 | 100% | ||
cryptowesearch | 0 | 13,925,840 | 100% | ||
cnbuddy-reward | 0 | 102,954,810,764 | 100% | ||
chris55 | 0 | 852,232,292 | 100% | ||
ladyalkaid | 0 | 1,605,105,510 | 100% | ||
lnakuma | 0 | 12,273,883,914 | 100% | ||
ibutterfly | 0 | 1,187,985,100 | 100% | ||
starnote | 0 | 104,285,849 | 48% | ||
lukgot | 0 | 3,988,697,245 | 100% | ||
aagod | 0 | 3,989,797,786 | 100% | ||
bo022 | 0 | 539,097,832 | 100% | ||
toni.pal | 0 | 0 | 0.98% | ||
rkogod | 0 | 3,987,009,690 | 100% | ||
wiggod | 0 | 3,981,072,366 | 100% | ||
huiwilkins | 0 | 3,982,208,791 | 100% | ||
huiwilkins2 | 0 | 3,982,253,099 | 100% | ||
moochain.net | 0 | 105,275,710 | 48% | ||
dinggle | 0 | 0 | 48% | ||
kengod | 0 | 3,982,404,995 | 100% | ||
biugod | 0 | 3,977,496,942 | 100% | ||
hunggod | 0 | 3,982,403,183 | 100% | ||
llgod | 0 | 3,976,202,252 | 100% | ||
aaken | 0 | 3,978,706,574 | 100% | ||
aarko | 0 | 3,977,695,217 | 100% | ||
moocer | 0 | 0 | 48% | ||
steem-zh | 0 | 0 | 48% | ||
kenchung1 | 0 | 34,103,457,007 | 100% | ||
kenchung2 | 0 | 1,938,077,414 | 100% | ||
kenchung3 | 0 | 1,937,371,749 | 100% | ||
kenchung4 | 0 | 1,936,186,472 | 100% | ||
kenchung5 | 0 | 1,935,598,722 | 100% | ||
kenchung6 | 0 | 1,934,661,117 | 100% | ||
kenchung7 | 0 | 1,934,933,965 | 100% | ||
kenchung8 | 0 | 1,935,522,294 | 100% | ||
kenchung9 | 0 | 1,935,322,181 | 100% | ||
kenchung10 | 0 | 1,935,989,062 | 100% | ||
youngoole | 0 | 0 | 48% | ||
steem.buzz | 0 | 1,820,725,951 | 100% | ||
catanknight | 0 | 2,457,345,127 | 100% | ||
wikicoin | 0 | 0 | 48% | ||
steemzh | 0 | 0 | 48% | ||
steemipfs | 0 | 0 | 48% | ||
littleksroad | 0 | 322,645,615,224 | 100% | ||
dryuen | 0 | 655,411,458 | 100% | ||
curation.bot | 0 | 0 | 0.17% | ||
kitrewq000 | 0 | 6,867,656,114 | 100% | ||
kikoxixi | 0 | 24,002,836,651 | 100% | ||
musiccccat | 0 | 429,272,197,572 | 100% | ||
alwaysthinking | 0 | 14,099,011,959 | 100% | ||
xiaomalailiao | 0 | 14,482,667,868 | 100% | ||
weiweilove | 0 | 3,249,209,855 | 100% |