先行占坑。
JWT = header + payload + signature
Claims:Registered Claims and User Claims
Tips:
Signature Stripping,需要強制使用指定signature生成算法;
可以有多個jwt;
頒發refresh token,并由refresh token 換取 access token,refresh token 擁有 black list,可以 hit cache或者db;
并發問題,可以設置寬限時間。
明文:header與payload是明文base64的,可以輕易獲取到。解決辦法有二:加密\解密或者使用ssl。
加密方式:
對稱加密HMAC。用同一密鑰來Create & Verify;
非對稱加密RSA-SSA。Private Key 用來 Create & Verify;Public Key 用來 Verify。這樣Authentication Server可以擁有Private Key;其他Server擁有Public Key。
生成證書
keytool,http://jingyan.baidu.com/article/b0b63dbfe18eff4a483070f4.html生成的是jks私鑰,然后cert證書公鑰;
New-SelfSignedCertificatehttps://technet.microsoft.com/library/hh848633
生成cert證書,包含私鑰
Export-PfxCertificate 然后生成pfx,或者在控制面板中的證書管理工具里,導出pfx
example:
New-SelfSignedCertificate -Type Custom -Subject "CN=Brilte PresentFish,OU=Yzbai,DC=brlite" -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.2","2.5.29.17={text}upn=yzbai@brlite.com") -KeyUsage DigitalSignature -KeyAlgorithm RSA -KeyLength 2048 -CertStoreLocation "C:\"
歡迎來訪本人的github上項目:https://github.com/yzbai/HB.Framework,一個輔助最新asp.net core 2 的框架類庫。