@@ -1303,8 +1303,9 @@ end
1303
1303
1304
1304
function approve (cache:: CachedCredentials , cred:: AbstractCredential , url:: AbstractString )
1305
1305
cred_id = credential_identifier (url)
1306
- if haskey (cache. cred, cred_id) && cred != = cache. cred[cred_id]
1307
- Base. shred! (cache. cred[cred_id])
1306
+ if haskey (cache. cred, cred_id)
1307
+ # Shred the cached credential we'll be overwriting if it isn't identical
1308
+ cred != = cache. cred[cred_id] && Base. shred! (cache. cred[cred_id])
1308
1309
end
1309
1310
cache. cred[cred_id] = cred
1310
1311
nothing
@@ -1313,7 +1314,8 @@ end
1313
1314
function reject (cache:: CachedCredentials , cred:: AbstractCredential , url:: AbstractString )
1314
1315
cred_id = credential_identifier (url)
1315
1316
if haskey (cache. cred, cred_id)
1316
- Base. shred! (cache. cred[cred_id])
1317
+ # Shred the cached credential if it isn't the `cred` passed in
1318
+ cred != = cache. cred[cred_id] && Base. shred! (cache. cred[cred_id])
1317
1319
delete! (cache. cred, cred_id)
1318
1320
end
1319
1321
nothing
@@ -1413,6 +1415,8 @@ function approve(p::CredentialPayload; shred::Bool=true)
1413
1415
cred = p. credential
1414
1416
cred === nothing && return # No credential was used
1415
1417
1418
+ # Each `approve` call needs to avoid shredding the passed in credential as we need
1419
+ # the credential information intact for subsequent approve calls.
1416
1420
if p. cache != = nothing
1417
1421
approve (p. cache, cred, p. url)
1418
1422
shred = false # Avoid wiping `cred` as this would also wipe the cached copy
@@ -1441,6 +1445,8 @@ function reject(p::CredentialPayload; shred::Bool=true)
1441
1445
cred = p. credential
1442
1446
cred === nothing && return # No credential was used
1443
1447
1448
+ # Note: each `reject` call needs to avoid shredding the passed in credential as we need
1449
+ # the credential information intact for subsequent reject calls.
1444
1450
if p. cache != = nothing
1445
1451
reject (p. cache, cred, p. url)
1446
1452
end
0 commit comments