Just one more thing: Session renewal #771
Replies: 2 comments 4 replies
-
|
A really nice approach to me! I use Next.js' App router at the moment and this looks like an overall improvement. |
Beta Was this translation helpful? Give feedback.
-
|
This is probably a noob question but I can't really find answer in the doc. What is the purpose of having an idle exp time and active exp time? I can understand that when it comes to token. Refresh token is used to fetch a new access token and access token is used to authenticate the request. But when it comes to session, why do we need 2 different expiration time? Why can't we just have one expiration time that gets extended every time we have a request coming in before the session expires? The document says Any help is appreciated! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, everyone!
I'm pretty happy with how beta of version 2 is coming along, and there's just one more minor breaking change left (#772). I'll be slowly adding new OAuth providers and maybe adapters from the backlog after that.
...but, there's one more thing I'd like to change; something I've been thinking about on and off since before v1. It's a big change internally but won't be a breaking change for like 99% of users.
I'm considering removing session renewal (with an asterisk). It's one of the more annoying parts of Lucia. With this change, we won't have to set a new cookie after session validation (= Next.js 13 will just work), and for native apps, we just removed race conditions and renewal requests. In other words, it'll just make Lucia easier for everyone.
So what's the replacement? Simple, instead of creating a new session whenever a session is idle, we just extend the active and idle period expiration. It's still just renewing sessions, just that we're re-using old ones. The only downside to this is that if a session id is stolen unnoticed, it'll be valid until the user signs out. However, you generally have bigger issues if someone has access to your device.
That said, for apps that require strict security measures, you now can add absolute timeouts to sessions with the newly introduced session attributes. You can also limit the device and location the session can be used by keeping track of user agents and IP addresses. And if you really need a new session id to be created, you can implement it manually.
Finally, to my understanding, Github.com and NextAuth uses this approach, so it's not something new.
The only breaking change is removing
Auth.renewSession(), but I think most people just useAuthRequest.validate().Beta Was this translation helpful? Give feedback.
All reactions