-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use wall-time for credential helper invalidation (#18413)
Previously we were using time intervals which excluded time spent with the system sleeping, which is not appropriate for expiring tokens which expire based on wall-time duration. Closes #18301. PiperOrigin-RevId: 529340767 Change-Id: I15e74e7bc87284f8ba53aedace955b29bd52df8e Co-authored-by: Daniel Wagner-Hall <[email protected]> Co-authored-by: keertk <[email protected]>
- Loading branch information
1 parent
bf82e7b
commit eb75087
Showing
3 changed files
with
47 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...in/java/com/google/devtools/build/lib/authandtls/credentialhelper/SystemMillisTicker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright 2023 The Bazel Authors. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package com.google.devtools.build.lib.authandtls.credentialhelper; | ||
|
||
import com.github.benmanes.caffeine.cache.Ticker; | ||
|
||
/** | ||
* SystemMillisTicker is a Ticker which uses the unix epoch as its fixed reference point. | ||
* | ||
* <p>It is preferable to com.github.benmanes.caffeine.cache.Ticker.SystemTicker because that class | ||
* doesn't increment its time-source while the system is asleep, which isn't appropriate when | ||
* expiring tokens which have wall-time-based expiry policies. | ||
*/ | ||
public class SystemMillisTicker implements Ticker { | ||
public static final SystemMillisTicker INSTANCE = new SystemMillisTicker(); | ||
|
||
private SystemMillisTicker() {} | ||
|
||
@Override | ||
public long read() { | ||
return System.currentTimeMillis() * 1_000_000; | ||
} | ||
} |