What is difference between private and public claims on jwt?
I'm confused with the difference between those two claims. From what I understand they are both custom claims. So what is the difference?
The jwt token is signed using private key. The auth server provides the public key publicly on a url in the form of JSON Web Key Set(JWKS). During verification the public keys are fetched. Here is an example of JWKS.
JWT Claims The value of a claim can be any JSON object. There are three types of claims: "registered," "public," and "private." You can find the list of registered and public claims in the official IANA Registry. You can also add any other custom claim to a JWT; these are known as "private claims."
private_key_jwt is one of client authentication methods defined in OpenID Connect Core 1.0, 9. Client Authentication. On a token request, a client crafts a digitally signed JWT assertion and includes it to the request.
Figure 1 shows that a JWT consists of three parts: a header, payload, and signature. The header typically consists of two parts: the type of the token, which is JWT, and the algorithm that is used, such as HMAC SHA256 or RSA SHA256. It is Base64Url encoded to form the first part of the JWT.
Custom claim names that are required to be collision resistant. Their names should be UUIDs or prefixed by a URL to create a safe namespace for them and avoid collisions.
Custom claim names that are not required to be collision resistant.
What is difference between private and public claims on jwt?
Only difference is public claims are required to be universally collision resistant while private claims are not.
Public claims are like public API that defined for public consumption. They should be well documented. RFC7519 defines several ways to do it.
Private claims are claims that are known only to the producer and consumer of a JWT. Private claim names are not collision-resistant and should be used with clear understanding of this and care...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With