Skip to content

token is still alive, when "exp" = NOW #646

Closed
@taisuke-fujimoto

Description

@taisuke-fujimoto

Describe the problem

I tried with the code below, but no exception occurred. (TokenExpiredException occurs when Clock is +1 second)
This means that token lifetime is NOW <= "exp"

// kotlin code
val expiresAt = Instant.now()
val token = JWT.create()
    .withExpiresAt(expiresAt)
    .sign(Algorithm.HMAC256("test"))

val verifier = (JWT.require(Algorithm.HMAC256("test")) as JWTVerifier.BaseVerification)
    .build(Clock.fixed(expiresAt, ZoneId.of("UTC")))

verifier.verify(token)

Shouldn't the token lifetime be NOW < "exp"?

I think this description is correct.
https://github.com/auth0/java-jwt/blob/master/EXAMPLES.md#datetime-claim-validation

Environment

  • Version of this library used: 4.2.1
  • Version of Java used: 11
  • Other modules/plugins/libraries that might be involved: Kotlin 1.7.22

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs investigationAn issue that has more questions to answer or otherwise needs work to fully understand the issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions