91

I generated a JWT and there are some claims which I understand well, but there is a claim called kid in header. Does anyone know what it means?

I generated the token using auth0.com

Spencer Kormos
  • 8,271
  • 3
  • 27
  • 44
tylkonachwile
  • 1,669
  • 2
  • 13
  • 26

2 Answers2

118

kid is an optional header claim which holds a key identifier, particularly useful when you have multiple keys to sign the tokens and you need to look up the right one to verify the signature.

Once a signed JWT is a JWS, consider the definition from the RFC 7515:

4.1.4. "kid" (Key ID) Header Parameter

The kid (key ID) Header Parameter is a hint indicating which key was used to secure the JWS. This parameter allows originators to explicitly signal a change of key to recipients. The structure of the kid value is unspecified. Its value MUST be a case-sensitive string. Use of this Header Parameter is OPTIONAL.

When used with a JWK, the kid value is used to match a JWK kid parameter value.

Community
  • 1
  • 1
cassiomolin
  • 113,708
  • 29
  • 249
  • 319
  • So it means that kid parameter can be used with HS256 algorithm only? right? – Aman Gupta Jan 18 '21 at 10:17
  • this answer is objectively correct, but sometimes its useful to keep track of the wrong answers out there - https://github.com/distribution/distribution/issues/813 – Dave Ankin Aug 22 '21 at 08:00
12

The kid (key ID) claim is an optional header claim, used to specify the key for validating the signature.

It is described here: http://self-issued.info/docs/draft-jones-json-web-token-01.html#ReservedHeaderParameterName

Lukas Kolletzki
  • 1,920
  • 2
  • 25
  • 29
  • 9
    Documentation drafts shouldn't be used as reference when the final version of the documentation is available. The `kid` claim has been moved from the JWT to the JWS and JWE specifications. – cassiomolin May 09 '17 at 13:15