79149110

Date: 2024-11-01 18:56:11
Score: 0.5
Natty:
Report link

I've encountered with the same issue and found the fix.

According to this comment on github the Iat claim requires to be set using epoch time. In your code we can see it is set using standard string format, which worked fine in previous versions.

Change this line:

new Claim(JwtRegisteredClaimNames.Iat, DateTime.UtcNow.ToString())

To this:

new Claim(JwtRegisteredClaimNames.Iat, new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds().ToString(), ClaimValueTypes.Integer64)

But as @Shaik Abid Hussain said, adding options.UseSecurityTokenValidators = true to your .AddAuthentication() should work, because it reverts to the legacy token validation behavior from .net 6 and 7, but it didn't worked for me.

Reasons:
  • Whitelisted phrase (-1): worked for me
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • User mentioned (1): @Shaik
  • Low reputation (1):
Posted by: Ondrej Konarik