Verifying jwt tokens [rsa]

孤街醉人 提交于 2019-12-05 23:17:24

Tokens can be digitally signed using a key pair, private and public, or hashed using a secret key:

  • RS256 :RSA KeyPair with SHA256. Token is signed with private key and verified using the public

  • HS256: HMAC key with SHA256. The key is the same to sign and verify

A compact JWT looks like this hhhhh.ppppp.sssss

  • hhhhh: Header of JWT, includes the algorithm used to sign the token. e.g {"alg":"RS256","typ":"JWT"}. Encoded in base64url

  • ppppp: Payload of JWT, include some useful claims like sub, iss or exp. Encoded in base64url

  • sssss: Signature of JWT , performed on the concatenation of the base64 url encoding of header and payload using the specified algorithm and encoded in base64. E.g b64(signature(hhhhhh.pppppp))

Answering your question, you are refering to RS256 using a key pair where the client verifies the token using the public key (a verification with HMAC key would mean client and server share the key)

The token is signed (not encrypted) with the algorithm I wrote above. To verify, the client verifies that signature match with the first part of the token hhhhhh.pppppp using the provided public key. Digital signature verification is a standard operation supported in all modern languages. Note that is not the same as encryption/decryption

you can get a detailed description of JWT auth tokens in official website https://jwt.io/introduction/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!