luceos I don't remember how much of the reasoning was described in my original PR of those changes, but from what I remember, this was the idea:
Previously there was no concept of regular tokens, remember me tokens or manually created tokens. This made it challenging for extensions to edit existing tokens without any hint as to their usage, and this prevented building the session management UI (which should finally ship in our next release). I also remember issues with the SQL queries required to filter results while the lifetime and last activity were stored as different columns, rather than storing the expiration date.
My PR refactored the system to add token types, while keeping it as simple as possible. There was no requirement for the expiration date to be stored in the database for this new system to work, so this was dropped. An extension could still re-introduce that system if it needs it.
The type-based access tokens also has an important role related to the future session management UI: if you customize tokens, you will probably need to update the management UI accordingly to show that those tokens are different. Having a separate type for your special session means you don't need to worry about changing how the native tokens are displayed.
I still believe hard-coded values for regular and remember is the most maintainable way to go for core, however I'm not sure the current values have to remain unchanged. In fact there was an archived open issue about adjusting the remember me lifetime flarum/issue-archive136 likewise we could discuss an optimal value for the regular token as well.
All of this is only part of the story though, there's also the Symfony session and cookie lifetimes. The regular token lifetime should only be long enough for the token to survive the Symfony session. A longer lifetime wouldn't help since the Symfony session would expire and break the link between the browser and that token anyway.
Any token that should survive the current browsing session would need to be a form of remember cookie.
Again, I think the easiest implementation for this would pretty much operate outside of the token API. Just have the extension add a new column to the tokens table, and clear remember tokens before their native expiration based on that new column. Or to re-use the same value for all sessions including existing sessions, store it on the users table and join the tables during a scheduled command.
I'm not seeing any issue implementing this with the current API.
The only thing we should fix is the point mentioned above by rob006 about session.lifetime
, we should make sure there is no way for the regular token to expire before the Symfony session, which can currently happen. The static
properties aren't an issue here either, we should just add a static method on SessionAccessToken
that allow setting the lifetime value, and set it to session.lifetime
in a service provider.
What I think is a more useful feature than customizable session lifetimes, is a session keep alive system. Which we already have available https://discuss.flarum.org/d/30542-davwheat-session-keep-alive-good-riddance-something-went-wrong