Skip to content

Concurrent session management #1978

Open

Description

@kieran-myopnotes

as stated in this message
It would be really cool if we could have built in session management for users

Is your feature request related to a problem? Please describe.
Currently concurrent sessions are allowed by default in serverpod. Pen testing identifies this as a minor security concern

Describe the solution you'd like
Larger companies deal with this by having a way in your account to view all of your current sessions associated with your account. Here you can see all of the devices and locations your currently signed into and manually sign them out / kick them out. It would be good if serverpod had ways to fetch this information and manage those sessions from the server.

Describe alternatives you've considered
Alternatively, it would also be good for getting simple solution out if you could just configure whether you allow concurrent sessions for a single user, whether new sessions on new devices should kick users out of their other sessions, etc.

Additional context
This was identified to us by an external pen test and upon investigation, we realised that the serverpod sessions are not interactive currently and are more of an under-the-hood feature that is not accessible. We were still able to pass the test however due to this being classified as a minor security risk

Activity

  1. added
    enhancement
    on Mar 4, 2024
  2. SandPod commented on Mar 4, 2024

    @SandPod
    Contributor

    Hey @kieran-novarca!

    Providing a good developer experience around this would be a real win for the Auth module.

    I don't think it should be that much work either. I am noting down some information about this here if you would either like to implement your own solution or provide a contribution to Serverpod on this if we don't get around to it fast enough.

    For each successful login attempt to the server, a unique token Is created and stored for that user. These are stored in the serverpod_auth_key table along with the connected userId. To ensure that only a single device is able to successfully authenticate there should only exist a single entry in that table with the userId.

    So, upon successful login, that table could be purged from the unique userId before a new record is stored.

    The table is accessed through the AuthKey model and associated database operations.

  3. SandPod commented on Jan 2, 2025

    @SandPod
    Contributor

    This request is very similair to: #2995

    We now provide multiple ways to sign out a user from all devices, we still however do not support doing this when a user signs in (ensuring that only a single devices is authenticated at a time).

  4. added
    area: authentication
    on Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: authenticationenhancement

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions