Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Usage of nbf in json web tokens

Tags:

jwt

nbf: Defines the time before which the JWT MUST NOT be accepted for processing

I found this definition about nbf in json web tokens. But still wondering what the usage of nbf is? Why we use this? Does it relate to the term of security?

Any idea would be appreciated.

like image 263
Vahid Najafi Avatar asked Apr 08 '17 08:04

Vahid Najafi


People also ask

What is NBF in JWT token?

nbf" (Not Before) Claim The "nbf" (not before) claim identifies the time before which the JWT MUST NOT be accepted for processing. The processing of the "nbf" claim requires that the current date/time MUST be after or equal to the not-before date/time listed in the "nbf" claim.

What is the purpose of NBF?

nbf (Not Before) Claim — Identifies the time before which the JWT token MUST NOT be accepted for processing. exp (Expiration Time) — Identifies the expiration time on or after which the JWT MUST NOT be accepted for processing.

What are JSON Web Tokens used for?

JWT, or JSON Web Token, is an open standard used to share security information between two parties — a client and a server. Each JWT contains encoded JSON objects, including a set of claims. JWTs are signed using a cryptographic algorithm to ensure that the claims cannot be altered after the token is issued.

What are the three parts of a JSON Web Token?

Figure 1 shows that a JWT consists of three parts: a header, payload, and signature.


1 Answers

It definitely is up to how you interpret the time.

One of possible scenarios I could make up is literally - when a token must last from some particular point in time til another point in time.

Say, you're selling some API or resource. And a client purchased access that lasts for one hour and the access starts tomorrow in the midday.

So you issue a JWT with:

  • iat set to now
  • nbf set to tomorrow 12:00pm
  • exp set to tomorrow 1:00pm
like image 198
zerkms Avatar answered Sep 19 '22 22:09

zerkms