Skip to content

Commit

Permalink
fix: jwt ttl issues
Browse files Browse the repository at this point in the history
  • Loading branch information
hejrobin committed Jul 8, 2024
1 parent d3762a9 commit bedb4d6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion private/generator-templates/env.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ config('HAKU_DATABASE_PASS', '');
// @note Integrity signing keys
config('HAKU_GENERAL_SIGNING_KEY', '%signingKey%');
config('HAKU_JWT_SIGNING_KEY', '%jwtSigningKey%');
config('HAKU_JWT_TOKEN_TTL', 900);
config('HAKU_JWT_TOKEN_TTL', 60 * 15);

// @note CORS
config('HAKU_CORS_MAX_AGE', 3600 * 24);
Expand Down
2 changes: 2 additions & 0 deletions vendor/Haku/Console/Commands/Upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ protected function applyChanges(): void
{
$files = $this->coreFiles();

deleteDirectory(resolvePath("private/generator-templates"));

foreach ($files as $file)
{
$source = resolvePath("private/{$file}");
Expand Down
7 changes: 6 additions & 1 deletion vendor/Haku/Jwt/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,15 @@
*
* @throws Haku\Jwt\TokenException
*/
function encodeToken(array $context, int $maxAge = HAKU_JWT_TOKEN_TTL): string
function encodeToken(array $context, ?int $maxAge): string
{
$token = new Token(Algorithm::HS256);

if (!$maxAge)
{
$maxAge = intval(HAKU_JWT_TOKEN_TTL ?? '60');
}

if (defined('HAKU_JWT_SIGNING_KEY') === false)
{
throw new TokenException('HAKU_JWT_SIGNING_KEY not set, add it to your config.');
Expand Down

0 comments on commit bedb4d6

Please sign in to comment.