Skip to content

Commit 363db63

Browse files
committed
Added a mechanism to stop proxty if it couldn't reauth during the window
1 parent 53742bb commit 363db63

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/tools/aws.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,14 @@ func Authenticate() {
8989
// CheckReauth checks if we have not yet authenticated, or need to authenticate within the next 15 minutes
9090
func CheckReauth() {
9191
for {
92-
if CodeArtifactAuthInfo.AuthorizationToken == "" || time.Now().Sub(CodeArtifactAuthInfo.LastAuth) > 45*time.Minute {
93-
log.Printf("%d minutes until the CodeArtifact token expires, attempting a reauth.", time.Now().Sub(CodeArtifactAuthInfo.LastAuth)/time.Minute)
92+
timeSince := time.Since(CodeArtifactAuthInfo.LastAuth).Minutes()
93+
// Panic and shut down the proxy if we couldn't reauthenticate within the 15 minute window for some reason.
94+
if timeSince > float64(60) {
95+
log.Panic("Was unable to re-authenticate prior to our token expiring, shutting down proxty...")
96+
}
97+
98+
if CodeArtifactAuthInfo.AuthorizationToken == "" || timeSince > float64(45) {
99+
log.Printf("%f minutes until the CodeArtifact token expires, attempting a reauth.", 60-timeSince)
94100
Authenticate()
95101
}
96102
// Sleep for 15 seconds for the next check

0 commit comments

Comments
 (0)