setup mercure
This commit is contained in:
parent
e6b575afd8
commit
5b137b71b2
|
|
@ -7,6 +7,7 @@ parameters:
|
||||||
aws_url: '%env(AWS_ENDPOINT)%'
|
aws_url: '%env(AWS_ENDPOINT)%'
|
||||||
aws_public_url: '%env(AWS_ENDPOINT)%'
|
aws_public_url: '%env(AWS_ENDPOINT)%'
|
||||||
aws_bucket: '%env(S3_PORTAL_BUCKET)%'
|
aws_bucket: '%env(S3_PORTAL_BUCKET)%'
|
||||||
|
mercure_secret: '%env(MERCURE_JWT_SECRET)%'
|
||||||
logos_directory: '%kernel.project_dir%/public/uploads/logos'
|
logos_directory: '%kernel.project_dir%/public/uploads/logos'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ use Lcobucci\JWT\Signer\Hmac\Sha256;
|
||||||
use Lcobucci\JWT\Signer\Key\InMemory;
|
use Lcobucci\JWT\Signer\Key\InMemory;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\Routing\Attribute\Route;
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
|
|
||||||
class MercureController extends AbstractController
|
class MercureController extends AbstractController
|
||||||
|
|
@ -16,15 +17,17 @@ class MercureController extends AbstractController
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
#[Route(path: '/mercure-token', name: 'mercure_token', methods: ['GET'])]
|
#[Route(path: '/mercure-token', name: 'mercure_token', methods: ['GET'])]
|
||||||
public function getMercureToken(): JsonResponse
|
public function getMercureToken(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
|
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
|
||||||
$user = $this->userService->getUserByIdentifier($this->getUser()->getUserIdentifier());
|
$user = $this->userService->getUserByIdentifier($this->getUser()->getUserIdentifier());
|
||||||
|
|
||||||
$topic = sprintf('http://portail.solutions-easy.moi/notifications/user/%d', $user->getId());
|
$domain = $request->getSchemeAndHttpHost();
|
||||||
|
|
||||||
|
$topic = sprintf('%s/notifications/user/%d', $domain, $user->getId());
|
||||||
|
|
||||||
// Generate JWT token for Mercure subscription
|
// Generate JWT token for Mercure subscription
|
||||||
$secret = $_ENV['MERCURE_JWT_SECRET'];
|
$secret = $this->getParameter('mercure_secret');
|
||||||
|
|
||||||
$config = Configuration::forSymmetricSigner(
|
$config = Configuration::forSymmetricSigner(
|
||||||
new Sha256(),
|
new Sha256(),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue