79792183

Date: 2025-10-16 13:16:41
Score: 0.5
Natty:
Report link

Just found the answer to this question after having the same problem.

The issue is in the jwt token generation

        return Jwts.builder()
                .setSubject(login)
                .setClaims(extraClaims)
                .setIssuedAt(new Date())
                .setExpiration(new Date(System.currentTimeMillis() + tokenValidity * 1000))
                .signWith(key)
                .compact();

If you look the the setSubject method you will find out that it's just a convenience method to set the sub claim if the Claims are not present. You are in fact filling a Claims object with the sub claim and then overriding it with your other extraClaims.

What i simply did was switch the order:

return Jwts.builder()
                  .setClaims(extraClaims)
                  .setSubject(login)
                  //etc

Guess you din't need the answer anymore, but maybe someone else will stumble here.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Me too answer (2.5): having the same problem
  • High reputation (-1):
Posted by: Zeromus