Skip to content

Conversation

@mostlygeek
Copy link
Contributor

Set the nbf (not before) claim to be a 5 minutes before the iat (issued at) claim to account for clock skew between tsidp and clients.

Fixes #73

@mostlygeek mostlygeek force-pushed the mostlygeek/nbf-time-skew-73 branch 2 times, most recently from f557ce9 to 09094eb Compare October 1, 2025 21:04
return
}

now := time.Now()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

just moved a few lines below and renamed now to iat - which is more descriptive of its use

}

// values for exp, nbp and iat claims
iat := time.Now()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

these are reused in the JWT token tsClaims as well as in updating the AuthRequest


// Create a refresh token from the access token with longer validity
rtAuth := *ar // copy the authRequest
rtAuth.ValidTill = iat.Add(RefreshTokenDuration)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

refresh tokens have a longer duration. Though we can probably tweak the scopes it has (future PR) to be less permissive.

fmt.Printf("❌ Error verifying ID Token: %v\n", err)
os.Exit(1)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

add checks in the verifier around the changed iat, exp, nbf logic

@mostlygeek mostlygeek self-assigned this Oct 1, 2025
@mostlygeek mostlygeek requested a review from mikeodr October 1, 2025 21:10
Copy link
Collaborator

@mikeodr mikeodr left a comment

Choose a reason for hiding this comment

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

LGTM, one minor logging fix for clarity if you agree.

Set the nbf (not before) claim to be a 5 minutes before the iat
(issued at) claim to account for clock skew between tsidp and clients.

Fixes #73

Signed-off-by: Benson Wong <benson@tailscale.com>
@mostlygeek mostlygeek force-pushed the mostlygeek/nbf-time-skew-73 branch from 09094eb to 7ba1edc Compare October 2, 2025 17:17
@mostlygeek mostlygeek merged commit 8b48d68 into main Oct 2, 2025
2 checks passed
@mostlygeek mostlygeek deleted the mostlygeek/nbf-time-skew-73 branch October 2, 2025 17:21
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.

Change nbf to allow clock skew between IdP and RP

2 participants