Skip to content

Commit 266688c

Browse files
committed
Fix preflight cache key token collisions
1 parent 0e6ddcc commit 266688c

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

lib/SeqeraApi.groovy

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ class SeqeraApi {
3636
}
3737

3838
static void validateApiAccess(String apiEndpoint, Map headers, String tokenEnvVar, String token) {
39-
def validationKey = "${apiEndpoint}|${tokenEnvVar}|${token.hashCode()}"
39+
def tokenDigest = java.security.MessageDigest.getInstance('SHA-256')
40+
.digest(token.getBytes('UTF-8'))
41+
.collect { String.format('%02x', it) }
42+
.join()
43+
def validationKey = "${apiEndpoint}|${tokenEnvVar}|${tokenDigest}"
4044
if (validatedApiSessions.contains(validationKey)) {
4145
return
4246
}

0 commit comments

Comments
 (0)