Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

h logs users out too frequently #8949

Closed
seanh opened this issue Sep 11, 2024 · 2 comments · Fixed by #8961
Closed

h logs users out too frequently #8949

seanh opened this issue Sep 11, 2024 · 2 comments · Fixed by #8961

Comments

@seanh
Copy link
Contributor

seanh commented Sep 11, 2024

Related: #8948

Inactive h users get logged out after seven days when their auth ticket expires, whereas active h users get logged out every thirty days when their auth cookie expires.

Both seven days and thirty days are far too aggressive: the inconvenience to our users (and likely resulting negative effect on user retention) for outweighs any improved security we might be getting by logging users out so often.

@seanh
Copy link
Contributor Author

seanh commented Sep 11, 2024

Possible solution:

  1. Inactive users stay logged in for much longer than currently, at least six months. I'd say one year.
  2. Active users stay logged in forever. As long as you make at least one request every year, you will never be logged out.

This is slightly complicated to implement. You have to track whether the user is active so you have to do something each time a user makes a request such as refreshing a cookie or ticket. (The current implementation does this by refreshing tickets).

Simpler version:

  • Both active and inactive users stay logged in forever, logins never time out at all.

This is simpler because we don't need to keep track of whether a user is active or not, so there's no need to refresh any cookie or tickets. Cookies and tickets don't even have expiry times.

A problem with this is that we have no way to purge no-longer-needed auth tickets from our DB. If auth tickets never expire then we can never purge any of them. Currently, h regularly purges auth tickets that've passed their expiry time. There may be other things we can do to prevent the auth_ticket table from growing too large, e.g. have only one ticket per user (shared by all that user's auth cookies).

Both solutions still need to deal with #8948 (the problem of the user getting logged out while they have a tab still open). In the first solution if a user leaves a tab open for a year (!) and is not active in any other tabs and then tries to return to the old tab, they'll see errors. In both solutions if the user has multiple tabs open and logs out in one tab and then tries to return to another open tab they'll run into errors.

@robertknight
Copy link
Member

I think we probably do want some eventual expiry time for logins, but it can be longer than it is today. For inactive users, we probably want it to be at least a month but not more than a year. If the duration is long enough, I don't think it is a big problem if active users are occasionally logged out. This happens to me with many of the services I use.

seanh added a commit that referenced this issue Sep 19, 2024
Fixes #8949. We agreed on logging
inactive users out after three months and active users after one year,
Slack thread:

https://hypothes-is.slack.com/archives/C4K6M7P5E/p1726753077108739?thread_ts=1726473609.158389&cid=C4K6M7P5E
seanh added a commit that referenced this issue Sep 19, 2024
Fixes #8949. We agreed on logging
inactive users out after three months and active users after one year,
Slack thread:

https://hypothes-is.slack.com/archives/C4K6M7P5E/p1726753077108739?thread_ts=1726473609.158389&cid=C4K6M7P5E
@seanh seanh closed this as completed in bdbe3ae Sep 19, 2024
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 a pull request may close this issue.

2 participants