Skip to content

Commit 5b19073

Browse files
committed
fix(token-lifetime): exposed auth token lifetime config to env var
1 parent d34dc0e commit 5b19073

2 files changed

Lines changed: 4 additions & 8 deletions

File tree

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ APP_VERSION=1
99
# Application environment
1010
APP_ENVIRONMENT=development
1111

12+
# Authentication token lifetime in seconds
13+
AUTH_TOKE_LIFE_TIME=86400
14+
1215
# CONNECTIVITY
1316

1417
# Server host ip

src/Auth/Token.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,9 @@
99

1010
final class Token
1111
{
12-
/**
13-
* Expiry time of token
14-
* Default = 24 * 60 * 60
15-
* @var int $expiryTime
16-
*/
17-
private static int $expiryTime = 8640;
18-
1912
public static function encode(array $user): string
2013
{
21-
$user['expiry'] = time() + self::$expiryTime;
14+
$user['expiry'] = time() + $_ENV['AUTH_TOKE_LIFE_TIME'];
2215
return JWT::encode(payload: $user, key: self::getAppKey(), alg: 'HS256');
2316
}
2417

0 commit comments

Comments
 (0)