Skip to content

fix: enable IssuedAt verification when WithIssuedAt() is used#524

Open
happysnaker wants to merge 1 commit into
golang-jwt:mainfrom
happysnaker:fix-issuedat-verification
Open

fix: enable IssuedAt verification when WithIssuedAt() is used#524
happysnaker wants to merge 1 commit into
golang-jwt:mainfrom
happysnaker:fix-issuedat-verification

Conversation

@happysnaker

Copy link
Copy Markdown

Summary

Fixes #489

The verifyIssuedAt call in the validator was passing false for the required parameter, which means IssuedAt would never actually be verified even when WithIssuedAt() was used by the caller.

Root Cause

In validator.go, the IssuedAt check is:

if v.verifyIat {
    if err = v.verifyIssuedAt(claims, now, false); err != nil {

The third parameter required controls whether the check is enforced. Passing false means the function only checks if the claim exists but doesn't actually validate it. Passing true enforces the check.

Changes

Changed false to true so that WithIssuedAt() actually enforces IssuedAt validation.

This is a one-character fix.

The verifyIssuedAt call in the validator was passing 'false' for
the 'required' parameter, which means IssuedAt would never actually
be verified even when WithIssuedAt() was used.

Changed to 'true' so that the iat claim is properly validated.

Fixes golang-jwt#489

@itxaiohanglover itxaiohanglover left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the correct fix — when verifyIat is enabled via WithIssuedAt(), the last parameter should be true to actually verify the claim. The existing tests should cover this. Any chance this could get reviewed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IssuedAt claim is not verified when jwt.WithIssuedAt() option is given to Parser

2 participants