-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Token/JWT] Add some leeway to jwt claims #19796
Conversation
Signed-off-by: Antoine Jouve <[email protected]>
Signed-off-by: Antoine Jouve <[email protected]>
Thank you for your contribution @an-toine, can you check if we could upgrade our dependency golang-jwt from v4 to v5? |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #19796 +/- ##
=======================================
Coverage 67.54% 67.54%
=======================================
Files 991 991
Lines 109171 109173 +2
Branches 2719 2719
=======================================
+ Hits 73739 73741 +2
+ Misses 31467 31465 -2
- Partials 3965 3967 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Signed-off-by: Antoine Jouve <[email protected]>
Head branch was pushed to by a user without write access
Signed-off-by: Antoine Jouve <[email protected]>
@MinerYang : fully agree, I will try to work on #19802 review by the end of the week. |
Comprehensive Summary of your change
On distributed systems, with Harbor deployed on multiple backend servers, it is not uncommon to observe some small discrepancies between server clocks, even with a reliable NTP source.
In such cases, a backend server may issue tokens with a
NotBefore
field set to a future timestamp for other servers, resulting in failed (403 unauthorized) image pulls for end users :As RFC7519 tolerates some leeway to be provided to account for clock skew, this PR is adding/substracting 10 seconds to fields
NotBefore
,ExpiresAt
andIssuedAt
.With golang-jwt v5.2.0, a leeway field is directly integrated in the Validator struct (https://github.com/golang-jwt/jwt/blob/v5.2.0/validator.go#L38). This PR is just emulating this behavior for the release currently in use in Harbor.
Issue being fixed
Fixes #18880
Please indicate you've done the following: