Skip to content

Commit 6b73188

Browse files
committed
cmd/cue: store token expiry timestamps in UTC in logins.json
That is, rather than a local-timezone timestamp such as "expiry": "2024-10-01T12:25:11.136734393+02:00" it is more consistent and straightforward to use UTC: "expiry": "2024-10-01T10:25:26.177186044Z" There should be zero change in the token refresh logic either way, but this will be easier for humans to grasp and debug. Signed-off-by: Daniel Martí <[email protected]> Change-Id: I673482b6c667eb4bea2f2d6c426ba077142e008a Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1202036 Unity-Result: CUE porcuepine <[email protected]> TryBot-Result: CUEcueckoo <[email protected]> Reviewed-by: Roger Peppe <[email protected]>
1 parent 25e0884 commit 6b73188

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

cmd/cue/cmd/login.go

+3
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ inside $CUE_CONFIG_DIR; see 'cue help environment'.
9797
return fmt.Errorf("cannot obtain the OAuth2 token: %v", err)
9898
}
9999

100+
// For consistency, store timestamps in UTC.
101+
tok.Expiry = tok.Expiry.UTC()
102+
100103
_, err = cueconfig.UpdateRegistryLogin(loginsPath, host.Name, tok)
101104

102105
if err != nil {

cmd/cue/cmd/testdata/script/login_immediate.txtar

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ grep -count=1 '"access_token"' cueconfig/logins.json
1414
# Ensure the contents of the token look correct.
1515
grep -count=1 '"access_token": "secret-access-token"' cueconfig/logins.json
1616
grep -count=1 '"token_type": "Bearer"' cueconfig/logins.json
17-
# TODO(mvdan): store expiry timestamps in UTC for consistency.
18-
grep '"expiry": "20..-..-..T' cueconfig/logins.json
17+
# Timestamps are always stored in UTC.
18+
grep '"expiry": "20..-..-..T.*Z"' cueconfig/logins.json
1919
# oauthregistry does not give a refresh token, and we use encoding/json's omitempty.
2020
! grep '"refresh_token"' cueconfig/logins.json

0 commit comments

Comments
 (0)