Giter Club home page Giter Club logo

Comments (11)

Spomky avatar Spomky commented on May 21, 2024 2

No that bundle does not extend the lifetime of the token.
It adds a flow to issue new tokens with user interaction.

When the bundle is installed an configured, your client will receive 2 tokens:

  • the token you already receive and that you use for your API calls,
  • a refresh token to issue new tokens.

At the moment, your client acts as below:

  1. Your client calls the API,
  2. The call is rejected because the token expired,
  3. Your client redirect the user to the login page and get a new access token,
  4. Your client calls the API and is granted

With the refresh token enabled, the step 3 is Your client calls the refresh token endpoint and get a new access token.

from lexikjwtauthenticationbundle.

slashfan avatar slashfan commented on May 21, 2024 1

It could work, you can change the ttl too, or configure your client application to ask for a new token periodically.

For the token invalidation, look at this cookbool entry and the IP flag examples, you should be able to customize the token validation by using the Events::JWT_CREATED and Events::JWT_DECODED events.

For example, you could configure an application wide key or hash, add it to the token payload and change it when you want to invalidate every token in the application.
If you just want to invalidate a specific user, store a user key directly in the user entity and change it when neeeded.

from lexikjwtauthenticationbundle.

slashfan avatar slashfan commented on May 21, 2024

Hi,

The token is only generated after the form login, there is no concept of "refreshing" or "renewing" in JWT. The TTL is part of the signature so you cannot update it without invalidating the token.

Once the token has expired you must generate a new one, either by asking for the user credentials or programatically.

Regards.

from lexikjwtauthenticationbundle.

mrcmorales avatar mrcmorales commented on May 21, 2024

@slashfan Thanks.

I saw that I can create new one with create method from JWTManager.

But How I can generate programatically new token when it has expired ? Because if token is expired I don't know If it is correct....

Thanks

from lexikjwtauthenticationbundle.

slashfan avatar slashfan commented on May 21, 2024

Hi, the only way I can think of would be to bypass the expiration checking, but I wouldn't recommand it.

from lexikjwtauthenticationbundle.

mrcmorales avatar mrcmorales commented on May 21, 2024

ok, then I'm thinking to generate new token every x time, and return allways the token in every request.

There is some method to remove the old token ?

Thanks

from lexikjwtauthenticationbundle.

stphane avatar stphane commented on May 21, 2024

Hi, I'm having trouble with the token validity.
I'm using the default token_ttl value, but users have to re-connect too often.
Can nelmio_cors "max_age" parameter interfer with the ttl_value and result in such an issue ?
Any idea ?
Thx

from lexikjwtauthenticationbundle.

Spomky avatar Spomky commented on May 21, 2024

The CORS will not help you in this case. When a token expires you have to issue a new one.
Using the gesdinet/JWTRefreshTokenBundle, your client will be able to renew a token with a refresh token.

from lexikjwtauthenticationbundle.

stphane avatar stphane commented on May 21, 2024

Thank you for reactivity.
You mean that I need to install whole of another bundle just in order to make token last longer ?
I must be missing something :(

from lexikjwtauthenticationbundle.

chalasr avatar chalasr commented on May 21, 2024

@stphane What about first setting the token_ttl with a greater value than the default one? Then, if you really need a refresh token mechanism for avoid requesting a new token from credentials, yes the solution proposed by @Spomky stay your best alternative, not from the bundle perspective, but in JWT in general.

from lexikjwtauthenticationbundle.

stphane avatar stphane commented on May 21, 2024

Thank you for details and advices.
By "reconnect to often" I meant like every 5 minutes.The default value of 84600 should cover an entire day right!?. I now suspect the appGyver developer to not join the token along some requests from inside the mobile application which cause itself to prompt its login form.
I will let you know once the developer has inspected his code.

from lexikjwtauthenticationbundle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.