Skip to content

Commit 3a8f11a

Browse files
authored
Merge pull request #68 from ydb-platform/ilyakharev-patch-1
Update saveToken function
2 parents 5359d7c + b48610f commit 3a8f11a

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
* updated saveToken function in Iam.php
2+
13
## 1.5.4
24

35
* fixed jwt authentication

src/Iam.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,11 +403,14 @@ protected function saveToken($token)
403403
$this->expires_at = $this->convertExpiresAt($token->expiresAt ?? '');
404404
$this->refresh_at = $token->refreshAt;
405405

406-
file_put_contents($tokenFile, json_encode([
406+
$randPath = $tokenFile."-tmp".bin2hex(random_bytes(10));
407+
file_put_contents($randPath, json_encode([
407408
'iamToken' => $this->iam_token,
408409
'expiresAt' => $this->expires_at,
409410
'refreshAt' => $this->refresh_at
410411
]));
412+
rename($randPath, $tokenFile);
413+
411414
}
412415

413416
/**

0 commit comments

Comments
 (0)