Skip to content

Commit 749b57a

Browse files
authored
Fix wrong check from #901 (#903)
1 parent cff7a69 commit 749b57a

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/Credentials/WebIdentityProvider.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,18 @@ private function getCredentialsFromRole(string $roleArn, string $tokenFile, ?str
128128
*/
129129
private function getTokenFileContent(string $tokenFile): string
130130
{
131-
if (!file_exists($tokenFile)) {
132-
$tokenDir = \dirname($tokenFile);
133-
$tokenLink = readlink($tokenFile);
134-
clearstatcache(true, $tokenDir . \DIRECTORY_SEPARATOR . $tokenLink);
135-
clearstatcache(true, $tokenDir . \DIRECTORY_SEPARATOR . \dirname($tokenLink));
136-
clearstatcache(true, $tokenFile);
131+
$token = @file_get_contents($tokenFile);
132+
133+
if (false !== $token) {
134+
return $token;
137135
}
138136

137+
$tokenDir = \dirname($tokenFile);
138+
$tokenLink = readlink($tokenFile);
139+
clearstatcache(true, $tokenDir . \DIRECTORY_SEPARATOR . $tokenLink);
140+
clearstatcache(true, $tokenDir . \DIRECTORY_SEPARATOR . \dirname($tokenLink));
141+
clearstatcache(true, $tokenFile);
142+
139143
if (false === $token = file_get_contents($tokenFile)) {
140144
throw new RuntimeException('Failed to read data');
141145
}

0 commit comments

Comments
 (0)