jwt简单应用
jwt应用图示
用来校验请求者是最初认证的.
jwt-structure
jwt实例
|
|
.
建jwt分为三段,前两端是header和payload的base64编码(可解码),
header解码后是:1234{ "typ": "JWT", "alg": "HS256"}
payload解码后是:1234567891011121314{ "iss": "Online JWT Builder", "iat": 1483156430, "exp": 1514692430, "aud": "www.example.com", "sub": "jrocket@example.com", "GivenName": "Johnny", "Surname": "Rocket", "Email": "jrocket@example.com", "Role": [ "Project Administrator", "sdfsef" ]}
最后的signature是将header和payload, 进过key按照加密算法(可选的hs256,hs384,hs512)生成的数字签名.
校验如下:123456//VERIFY SIGNATUREHMACSHA256( base64UrlEncode(header) + "." + base64UrlEncode(payload), abc /*key*/)
deomo
|
|
|
|