Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cant override expiration / ttl #521

Closed
do-web opened this issue Jul 2, 2018 · 4 comments
Closed

Cant override expiration / ttl #521

do-web opened this issue Jul 2, 2018 · 4 comments
Labels

Comments

@do-web
Copy link

do-web commented Jul 2, 2018

It is not possible to override the default expiration time to unlimited.

$encoder = $this->container->get('lexik_jwt_authentication.encoder');
$token = $encoder->encode(['email' => $data->getEmail()]);

With the manager it is also not possible:

$jwtManager = $this->container->get('lexik_jwt_authentication.jwt_manager');
$token = $jwtManager->create($newJwtUser);

I also tried this to remove expiration for unlimited lifetime:

public function onJWTCreated(JWTCreatedEvent $event)
{
    $payload        = $event->getData();
    $payload['exp'] = null;
// unset($payload['exp']); also not working

    $event->setData($payload);
}
@chalasr chalasr added the Feature label Jul 3, 2018
@alexsegura
Copy link

alexsegura commented Aug 2, 2018

I also want to generate token that never expires.
The example in the docs is wrong.

This is because the exp claim is actually added by the JWSProviderInterface implementation, whenever there is a ttl defined.

I see no easy way to do this ☹️
The only way I found is by overriding a bunch of services:

lexik_jwt_authentication.jws_provider.not_expiring:
  public: true
  parent: Lexik\Bundle\JWTAuthenticationBundle\Services\JWSProvider\JWSProviderInterface
  arguments:
    index_3: ~

lexik_jwt_authentication.encoder.not_expiring:
  parent: lexik_jwt_authentication.encoder
  arguments:
    index_0: '@lexik_jwt_authentication.jws_provider.not_expiring'

lexik_jwt_authentication.jwt_manager.not_expiring:
  parent: lexik_jwt_authentication.jwt_manager
  arguments:
    index_0: '@lexik_jwt_authentication.encoder.not_expiring'

@alexsegura
Copy link

@chalasr I think this is fixed in #503, isn't it?

@alexsegura
Copy link

Nope, actually you still can't unset the exp key, the token will be considered as invalid.

@do-web @chalasr I created a Pull Request to make the exp claim optional → #583

@chalasr
Copy link
Collaborator

chalasr commented Sep 16, 2021

Closing for the reasons explained in #583.

@chalasr chalasr closed this as completed Sep 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants