-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Bug in bearer token expiration check #3779
Comments
Good catch. I wonder if a better patch would be to wrap the |
vlad-ivanov-name
pushed a commit
to vlad-ivanov-name/buildkit
that referenced
this issue
Apr 7, 2023
vlad-ivanov-name
pushed a commit
to vlad-ivanov-name/buildkit
that referenced
this issue
Apr 7, 2023
vlad-ivanov-name
added a commit
to vlad-ivanov-name/buildkit
that referenced
this issue
Apr 7, 2023
vlad-ivanov-name
added a commit
to vlad-ivanov-name/buildkit
that referenced
this issue
Apr 7, 2023
Signed-off-by: Vladislav Ivanov <[email protected]>
Good point. I opened a PR. I'm still getting sporadic 401s with this patch, but the frequency appears to be reduced significantly. I'm now running docker with additional logging in buildkit authorizer to hopefully catch the remaining bit. |
crazy-max
added a commit
that referenced
this issue
Apr 14, 2023
Fix bearer token expiration check (fixes #3779)
tonistiigi
pushed a commit
to tonistiigi/buildkit
that referenced
this issue
Apr 20, 2023
Signed-off-by: Vladislav Ivanov <[email protected]> (cherry picked from commit fc834f5)
moeghanem
pushed a commit
to moeghanem/buildkit
that referenced
this issue
Apr 27, 2023
Signed-off-by: Vladislav Ivanov <[email protected]> Signed-off-by: Moe Ghanem <[email protected]>
kattmang
pushed a commit
to kattmang/buildkit-cache-manifest-oci
that referenced
this issue
May 1, 2023
Signed-off-by: Vladislav Ivanov <[email protected]>
2 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bearer tokens expire after a while. Tokens also have an issue timestamp. Sometimes, that timestamp is zero, in which case buildkit takes current time as a reference point.
However, it fails to reliably detect when the timestamp is zero. It's using golang
time.Time.IsZero()
function, which checks whether the time isJanuary 1, year 1, 00:00:00 UTC
, but the timestamp is converted from Unix time. Therefore,01-01-1970
is compared to01-01-0001
, which always yieldsfalse
, and results in expiry time being recorded as time before issue timestamp, always at01-01-0001
.buildkit/util/resolver/authorizer.go
Line 336 in 3187d2d
buildkit/util/resolver/authorizer.go
Line 359 in 3187d2d
Later in the code, there's a condition that reuses cached tokens if expiry time
IsZero
OR if the expiry time has passed. Because of the bug before,IsZero
always returns true, making buildkit use expired tokens.buildkit/util/resolver/authorizer.go
Lines 303 to 305 in 3187d2d
This results in errors, e. g.
401 Unauthorized
when using Google Artifact RegistryExample patch:
The text was updated successfully, but these errors were encountered: