Skip to content

Commit

Permalink
Merge pull request #12625 from playframework/mergify/bp/2.9.x/pr-12624
Browse files Browse the repository at this point in the history
[2.9.x] Fix jjwt compatibility to allow upgrades (backport #12624) by @mkurz
  • Loading branch information
mergify[bot] committed May 8, 2024
2 parents ae8abc0 + fef9411 commit dd0463d
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions core/play/src/main/scala/play/api/mvc/Cookie.scala
Expand Up @@ -794,8 +794,23 @@ object JWTCookieDataCodec {
builder.setExpiration(expirationDate)
}

builder.setNotBefore(now) // https://tools.ietf.org/html/rfc7519#section-4.1.5
builder.setIssuedAt(now) // https://tools.ietf.org/html/rfc7519#section-4.1.6
try {
builder.setNotBefore(now) // https://tools.ietf.org/html/rfc7519#section-4.1.5
} catch {
case _: NoSuchMethodError => // In case users upgrade to jjwt 0.12+
classOf[JwtBuilder]
.getDeclaredMethod("notBefore", classOf[java.util.Date])
.invoke(builder, now)
}

try {
builder.setIssuedAt(now) // https://tools.ietf.org/html/rfc7519#section-4.1.6
} catch {
case _: NoSuchMethodError => // In case users upgrade to jjwt 0.12+
classOf[JwtBuilder]
.getDeclaredMethod("issuedAt", classOf[java.util.Date])
.invoke(builder, now)
}

// Sign and compact into a string...
// Even though secretKey already knows about the algorithm we have to pass signatureAlgorithm separately as well again.
Expand Down

0 comments on commit dd0463d

Please sign in to comment.