What is the difference between JSON Web Signature (JWS) and JSON Web Token (JWT)?

前端 未结 2 852
萌比男神i
萌比男神i 2021-02-01 12:13

I\'ve been coding a RESTful service in Java. This is what I\'ve understood till now (correct me if i\'m wrong):

Token authorization is done using JSON Web Tokens (JW

2条回答
  •  你的背包
    2021-02-01 12:58

    JWT actually uses JWS for its signature, from the spec's abstract:

    JSON Web Token (JWT) is a compact, URL-safe means of representing claims to be transferred between two parties. The claims in a JWT are encoded as a JavaScript Object Notation (JSON) object that is used as the payload of a JSON Web Signature (JWS) structure or as the plaintext of a JSON Web Encryption (JWE) structure, enabling the claims to be digitally signed or MACed and/or encrypted.

    So a JWT is a JWS structure with a JSON object as the payload. Some optional keys (or claims) have been defined such as iss, aud, exp etc.

    This also means that its integrity protection is not just limited to shared secrets but public/private key cryptography can also be used.

提交回复
热议问题