Skip to content

New plugin: Persisted login#9976

Open
pabzm wants to merge 1 commit into
masterfrom
persisted-login-plugin
Open

New plugin: Persisted login#9976
pabzm wants to merge 1 commit into
masterfrom
persisted-login-plugin

Conversation

@pabzm

@pabzm pabzm commented Sep 12, 2025

Copy link
Copy Markdown
Member

This plugin adds a toggle switch into the login form of Roundcubemail's "elastic" skin, that makes the session live for a configured number of days.

Adapted from #8689

Hat tip and thanks to @Github-Citizen

@pabzm pabzm requested a review from alecpl September 12, 2025 18:35
@pabzm

pabzm commented Sep 12, 2025

Copy link
Copy Markdown
Member Author

The E2E-tests are green locally. I'll fix them in the CI next week.

Comment thread plugins/persisted_login/README.md Outdated
Comment thread plugins/persisted_login/LICENSE Outdated
Comment thread plugins/persisted_login/persisted_login.php Outdated
Comment thread plugins/persisted_login/persisted_login.php
Comment thread plugins/persisted_login/persisted_login.php Outdated
Comment thread plugins/persisted_login/persisted_login.js Outdated
@pabzm pabzm force-pushed the persisted-login-plugin branch from 1f9032c to 96424bd Compare September 15, 2025 09:55
@pabzm

pabzm commented Sep 15, 2025

Copy link
Copy Markdown
Member Author

Thank you for the review! I changed the styling as requested and added support for derivate skins.

@pabzm pabzm requested a review from alecpl September 15, 2025 09:55
@pabzm pabzm moved this to 🏗️ In progress in 💌 📅 👥 Groupware team Sep 16, 2025
@pabzm pabzm self-assigned this Sep 16, 2025
@pabzm pabzm force-pushed the persisted-login-plugin branch from 96424bd to eaeaba2 Compare September 16, 2025 10:53
@pabzm

pabzm commented Sep 17, 2025

Copy link
Copy Markdown
Member Author

The PHP8.5 deprecation warning in the Unit tests is fixed via DASPRiD/Enum#18

This plugin adds a toggle switch into the login form of Roundcubemail's "elastic" skin, that makes the session live for
a configured number of days (instead of only for the session).
@pabzm pabzm force-pushed the persisted-login-plugin branch from eaeaba2 to 492aa33 Compare September 17, 2025 12:19
@pabzm

pabzm commented Sep 17, 2025

Copy link
Copy Markdown
Member Author

I fixed the Browser tests by changing the plugin behaviour a little bit: It now uses a default of 7 days, and a minimum of 1 day. Setting persisted_login_days to 0 doesn't work anymore to disable the plugin. Instead disabling should be done via config.inc.php. Additionally the config file is included as config.inc.php.dist, as it is in other plugins.
I think it's even more logical this way.

@alecpl

alecpl commented Sep 21, 2025

Copy link
Copy Markdown
Member

A composer.json file is missing.

ps. I don't like one thing about this plugin. It changes session lifetime for everyone. Which means all session records are garbage collected after X days. It probably should be fixed with a "expires at" column in the session table. It's not a stopper, I suppose.

@Github-Citizen

Copy link
Copy Markdown
Contributor

ps. I don't like one thing about this plugin. It changes session lifetime for everyone. Which means all session records are garbage collected after X days.

Yes, but isn't that a necessary evil? If you don't extend the 'session_lifetime' then GC will remove the server side session even though the browser cookie is saved in the browser for x number of days.

It probably should be fixed with a "expires at" column in the session table. It's not a stopper, I suppose.

But doesn't that require a fundamental change to the core of roundcube and outside of the scope of a plugin?

@pabzm

pabzm commented Sep 23, 2025

Copy link
Copy Markdown
Member Author

I also don't really like to rely on the clients to respect the expiry-timestamp of the cookie, either, but decided to go with it for now.

But as we agree on that part maybe we should do it properly and implement this features in core code, using an expire_at database column and memcache/redis key. Because having it in a plugin while changing core code explicitly for it feels wrong to me.

@alecpl Do you agree?

@pabzm

pabzm commented Sep 24, 2025

Copy link
Copy Markdown
Member Author

And as far as I see we don't need the changed column anymore, and should remove it – or rather rename it, instead of adding and removing.

@alecpl

alecpl commented Sep 24, 2025

Copy link
Copy Markdown
Member

And as far as I see we don't need the changed column anymore, and should remove it – or rather rename it, instead of adding and removing.

What do you mean we don't need it? It is a very important column. We'd need both changed and expires_at.

@pabzm

pabzm commented Sep 24, 2025

Copy link
Copy Markdown
Member Author

From the code in rcube_session_db I figured that the purpose of changed is to mark the latest use of a session, so expired sessions can be filtered and removed. That could be done using expires_at instead, I think. What other purpose is there to changed?

@pabzm

pabzm commented Sep 26, 2025

Copy link
Copy Markdown
Member Author

In c69f02f (branch extended-session-lifetime) I built a proof of concept of the feature in core code, which works without changed. It's not polished, but it works. Could you let me know which problems you see or would expect?

@alecpl

alecpl commented Sep 27, 2025

Copy link
Copy Markdown
Member

You might be right that one column would suffice. However, "time since the last change" is not the same as "time to expiry"

It would be easier to review if I could see the changed -> expires_at change separately from the persistent login.

@pabzm

pabzm commented Sep 28, 2025

Copy link
Copy Markdown
Member Author

Here's a PR with only the change to the session expiry without the new feature: #9990

"time since the last change" is not the same as "time to expiry"

You're right, but as far as I can tell we use the timestamp only for expiry, and not for anything else.

@pabzm pabzm removed their assignment Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants