Skip to content

Commit

Permalink
Fix JWT token refresh
Browse files Browse the repository at this point in the history
Signed-off-by: Paolo Di Tommaso <[email protected]>
  • Loading branch information
pditommaso committed Dec 20, 2024
1 parent d9f699e commit 52a5ebd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/main/groovy/io/seqera/wave/tower/auth/JwtMonitor.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,12 @@ class JwtMonitor implements Runnable {
}

log.trace "JWT refresh request - entry=$entry; deadline=$deadline"
towerClient.userInfo(entry.endpoint, entry)
try {
// note: use 'force' to ignore client cache and refresh the jwt token
towerClient.userInfo(entry.endpoint, entry, true)
} catch (Throwable t) {
log.error("Unexpected error in JWT heartbeat while processing entry: ${entry}", t)
}
jwtTimeStore.setRefreshTimer(key)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ class TowerClient {
return cache.getOrCompute(cacheKey, (k)-> getAsync(uri, endpoint, auth, type).get())
}

UserInfoResponse userInfo(String towerEndpoint, JwtAuth authorization) {
UserInfoResponse userInfo(String towerEndpoint, JwtAuth authorization, boolean force=false) {
final uri = userInfoEndpoint(towerEndpoint)
if( force )
return getAsync(uri, towerEndpoint, authorization, UserInfoResponse).get()
final k = RegHelper.sipHash(uri, authorization.key, null, null)
// NOTE: it assumes the user info metadata does nor change over time
// and therefore the *long* expiration cached is used
Expand Down

0 comments on commit 52a5ebd

Please sign in to comment.