symfony / mercure

The Mercure Component allows to easily push updates to web browsers and other HTTP clients using the Mercure protocol.
https://symfony.com/doc/current/components/mercure.html
MIT License
413 stars 39 forks source link

Patch for setting the lifetime of the cookie #83

Closed Charles-Emmanuel-DEZANDEE closed 3 weeks ago

Charles-Emmanuel-DEZANDEE commented 2 years ago

I'm working on auto-generating private topics read permission.

My subscriber use :

$this->discovery->addLink($request);
$this->authorization->setCookie(
        request: $request,
        subscribe: ['https://' . $_ENV['SERVER_NAME'] . User::USER_URI . '/' . $user->getId()],
        additionalClaims: ['exp' => new \DateTimeImmutable("+86400 seconds")]
);

Method setCookie use LcobucciFactory->create(...) and Builder->expiresAt(DateTimeImmutable $expiration).

I use Authorization->setCookie(...) and i want set expiration cookie with additionalClaims: ['exp' => 86400] and not with additionalClaims: ['exp' => new \DateTimeImmutable("+86400 seconds")]. An exception is thrown if a DateTimeImmutable is not used.

dunglas commented 3 weeks ago

Hi,

Thanks for your contribution. I'm not sure that we want to support this use case. What's the problem with passing a DateTime instance?