Skip to content

Commit 782b2fc

Browse files
committed
jwt variables from env issue fixed
1 parent e15654f commit 782b2fc

File tree

1 file changed

+7
-3
lines changed
  • src/BackendBase/Infrastructure/Ui/PrivateApi/IdentityAndAccess/Handler

1 file changed

+7
-3
lines changed

src/BackendBase/Infrastructure/Ui/PrivateApi/IdentityAndAccess/Handler/StartSession.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,18 @@ class StartSession implements RequestHandlerInterface
2828
private UserRepository $userRepository;
2929
private RedisRateLimiter $redisRateLimiter;
3030
private RolesRepository $rolesRepository;
31+
private array $config;
3132

3233
public function __construct(
3334
UserRepository $userRepository,
3435
RolesRepository $rolesRepository,
35-
RedisRateLimiter $redisRateLimiter
36+
RedisRateLimiter $redisRateLimiter,
37+
array $config
3638
) {
3739
$this->userRepository = $userRepository;
3840
$this->redisRateLimiter = $redisRateLimiter;
3941
$this->rolesRepository = $rolesRepository;
42+
$this->config = $config;
4043
}
4144

4245
public function handle(ServerRequestInterface $request) : ResponseInterface
@@ -58,15 +61,16 @@ public function handle(ServerRequestInterface $request) : ResponseInterface
5861
throw UserNotFound::create('Invalid username and/or password');
5962
}
6063

61-
$key = InMemory::base64Encoded('d81c8751fdd0a01e62b7acac5bea23a0d7d29beb03e428b863d02376aea628c1');
64+
$key = InMemory::base64Encoded($this->config['jwt']['key']);
6265
$configuration = Configuration::forSymmetricSigner(
6366
new Sha256(),
6467
$key
6568
);
6669

6770
$now = new DateTimeImmutable();
6871
$token = $configuration->builder()
69-
->issuedBy('storage')
72+
->issuedBy($this->config['jwt']['issuer'])
73+
->identifiedBy($this->config['jwt']['identifier'])
7074
->issuedAt($now) // Configures the time that the token was issue (iat claim)
7175
->canOnlyBeUsedAfter($now) // Configures the time that the token can be used (nbf claim)
7276
->expiresAt($now->modify('+12 hours')) // Configures the expiration time of the token (exp claim)

0 commit comments

Comments
 (0)