Implemented interaction with docker registry.
This commit is contained in:
26
app/application/app/Services/Registry/V2/JwtCommand.php
Normal file
26
app/application/app/Services/Registry/V2/JwtCommand.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Services\Registry\V2;
|
||||
|
||||
use App\Dto\Service\Registry\V2\AuthorizationConfig;
|
||||
use Firebase\JWT\JWT;
|
||||
|
||||
final readonly class JwtCommand
|
||||
{
|
||||
public function __construct(
|
||||
private KidCommand $kidCommand,
|
||||
private ContentPrivateKeyCommand $contentPrivateKeyCommand,
|
||||
) { }
|
||||
|
||||
public function execute(AuthorizationConfig $authorizationConfig, array $payload): string
|
||||
{
|
||||
$contentPrivateKey = $this->contentPrivateKeyCommand->execute($authorizationConfig->getPrivateKeyName());
|
||||
|
||||
return JWT::encode(
|
||||
$payload,
|
||||
$contentPrivateKey,
|
||||
$authorizationConfig->getAlgorithm(),
|
||||
$this->kidCommand->execute($authorizationConfig->getPrivateKeyName(), $contentPrivateKey)
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user