GitBook——統(tǒng)一接口認(rèn)證解決方案
目前創(chuàng)新互聯(lián)公司已為1000多家的企業(yè)提供了網(wǎng)站建設(shè)、域名、虛擬主機(jī)、網(wǎng)站運(yùn)營(yíng)、企業(yè)網(wǎng)站設(shè)計(jì)、撫順縣網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長(zhǎng),共同發(fā)展。JsonWebToken關(guān)于JsonWebToken的專業(yè)名詞解釋:
JsonWebToken主體分為三個(gè)部分:header、payload、signature
unsecured JWT結(jié)果示例:
eyJhbGciOiJub25lIn0.
eyJqdGkiOiJkZWJhNzhiZDZiNTI0ZTA2OWE4MmZjZTJlNzdmOTU2MSIsImlzcyI6Ik1hdGVNYXN0ZXIiLCJzdWIiOiLmnInmlYjotJ_ovb3mtYvor5UiLCJhdWQiOiJhdWRpZW5jZSIsImV4cCI6MTY3MDExNzIzMywibmJmIjoxNjcwMDMwODkzLCJpYXQiOjE2NzAwMzA4MzN9.
{"alg": "HS256",
"typ": "JWT",
"cty": ""
}
{"jti": "4a9813f957b84dda8091510402e7c33d",
"iss": "MateMaster",
"sub": "有效負(fù)載測(cè)試",
"aud": "audience",
"exp": 1670054958,
"nbf": 1669968618,
"iat": 1669968558
}
JWSJWS(Signed JWT)compact序列化主要生成流程:
結(jié)果示例
eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.
eyJpc3MiOiJtYXRlbWFzdGVyIiwic3ViIjoiandzIiwiYXVkIjoiYXVkaWVuY2UiLCJleHAiOjE2NzAwMzQ4NjEsImlhdCI6MTY3MDAzNDgwMSwibmJmIjoxNjcwMDM0ODAxLCJqdGkiOiIzNTA3M2FhYmMxMmU0ZDUzOTBkNGNjOGFlYzVhNmVlYyJ9.
pKhj-QPDszduhet_SZW6BfsLX0n88D__YvIHvfj87OSitCRq1ybb7Bc3ClZZfhf_ewgrhVUL4d4WK0JuCkl0gA
難點(diǎn):
JWS JSON序列化
JWS JSON 序列化形式(多個(gè)簽名)
{"payload": "eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogIm h0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ",
"signatures": [
{"protected": "eyJhbGciOiJSUzI1NiJ9",
"header": {"kid": "2010-12-29"
},
"signature": "cC4hiUPoj9Eetdgtv3hF80EGrhuB__dzERat0XF9g2VtQgr9PJbu3XOiZj5RZmh7AA uHIm4Bh-0Qc_lF5YKt_O8W2Fp5jujGbds9uJdbF9CUAr7t1dnZcAcQjbKBYNX4BAyn RFdiuB--f_nZLgrnbyTyWzO5vRK5h6xBArLIARNPvkSjtQBMHlb1L07Qe7K0GarZRmB _eSN9383LcOLn6_dO--xi12jzDwusC-eOkHWEsqtFZESc6BfI7noOPqvhJ1phCnvWh6 IeYI2w9QOYEUipUTI8np6LbgGY9Fs98rqVt5AXLIhWkWywlVmtVrBp0igcN_IoypGlU PQGe77Rw"
},
{"protected": "eyJhbGciOiJFUzI1NiJ9",
"header": {"kid": "e9bc097a-ce51-4036-9562-d2ade882db0d"
},
"signature": "DtEhU3ljbEg8L38VWAfUAqOyKAM6-Xx-F4GawxaepmXFCgfTjDx w5djxLa8ISlSApmWQxfKTUJqPP3-Kg6NU1Q"
}
]
}
扁平化JWS JSON 序列化形式(單個(gè)簽名)
{"payload": "eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQog Imh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ",
"protected": "eyJhbGciOiJFUzI1NiJ9",
"header": {"kid": "e9bc097a-ce51-4036-9562-d2ade882db0d"
},
"signature": "DtEhU3ljbEg8L38VWAfUAqOyKAM6-Xx-F4GawxaepmXFC gfTjDxw5djxLa8ISlSApmWQxfKTUJqPP3-Kg6NU1Q"
}
JSON 序列化與 compact序列化的區(qū)別:
JWS JSON字段含義
payload:base64編碼的JWT負(fù)載字符串
protected:base64編碼的JWS頭部字符串,包含的聲明受到簽名保護(hù)
signatures:簽名數(shù)組,header:不受簽名保護(hù)的header,在unprotected header中是必須的,在protected中是可選的,signature:base64編碼的JWS簽名字符串
重點(diǎn)知識(shí):
在JWS中,Share SecretKey,各方都可以驗(yàn)證和生成令牌。在公鑰/私鑰中,只有私鑰可以驗(yàn)證、生成令牌,公鑰只可以驗(yàn)證令牌,不能用于生成令牌
從生產(chǎn)者與消費(fèi)者角度理解JWS
JWE(Encrypted JWT)compact序列化主要生成流程:
JWE(Encrypted JWT)compact序列化組成部分:
base64(header)
base64(encryptedKey) [step 2,3]
base64(initializationVector) [step 4]
base64(cipherText) [step 6]
base64(authenticationTag) [step 6]
eyJhbGciOiJBMTI4S1ciLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0.
Y2DxdVnvuDwo5vutvvPg4PpGQKFmRxWoDUCtfs58Gv5rJ4J1RkSOUQ.
-Iu2VusgO_w0uWrn0JWx3Q.
krW8miBqh5x3dZ6ktf0C_A.
HHYK0TxHth2949NDPpwTsw
重點(diǎn)知識(shí):
在JWE中,Share SecretKey,各方都可以加密解密令牌。在對(duì)稱加密中,只有公鑰可以加密數(shù)據(jù),私鑰解密
從生產(chǎn)者與消費(fèi)者角度理解JWE
JWK的出現(xiàn)旨在,為不同加密密鑰提供一個(gè)統(tǒng)一的格式標(biāo)準(zhǔn)
JWK樣例
{"kty": "EC",
"crv": "P-256",
"x": "MKBCTNIcKUSDii11ySs3526iDZ8AiTo7Tu6KPAqv7D4",
"y": "4Etl6SRW2YiLUrN5vfvVHuhp7x8PxltmWWlbbM4IFyM",
"d": "870MB6gfuTJ4HtUnUvYMyJpr5eUZNP4Bk43bVdj3eAE",
"use": "enc",
"kid": "1"
}
持續(xù)更新中…………
你是否還在尋找穩(wěn)定的海外服務(wù)器提供商?創(chuàng)新互聯(lián)www.cdcxhl.cn海外機(jī)房具備T級(jí)流量清洗系統(tǒng)配攻擊溯源,準(zhǔn)確流量調(diào)度確保服務(wù)器高可用性,企業(yè)級(jí)服務(wù)器適合批量采購(gòu),新人活動(dòng)首月15元起,快前往官網(wǎng)查看詳情吧