| Would be nice to see alternative documents for similar topics (e.g. something like OWASP Cheatsheet but from more practical point of view). With all the respect, I'm a bit skeptical about this document for such reasons: - Name is quite pompous. It's a very good marketing trick: calling some document like if it was written by group of researchers from a Copenhagen university. :) Yes, Lucia is a relatively popular library but it doesn't mean that it is promoting best practices and that its author should be considered an authority in such important field unless opposite is proven. - I don't like some aspects of Lucia library design: when user token is almost expired - instead of generating new security token Lucia suggesting just to extend life of existing one. I see it as a very insecure behavior: token lives forever and can be abused forever. This violates one of the security best practices of limited token lifetime. But both Lucia and "Copenhagen Book" encourages this practice [1]: ```
if time.Now().After(session.expiresAt.Sub(sessionExpiresIn / 2)) {
session.ExpiresAt = time.Now().Add(
updateSessionExpiration(session.Id, session.ExpiresAt)
}
``` [1]: https://thecopenhagenbook.com/sessions#session-lifetime |
The link you posted shows code to extend the session, which is common practice (it's called rolling session), not to "extend" the token's life (which should be impossible, a token needs to be immutable in the first place, which is why refreshing a token gives you a new token instead of mutating the original).