Skip to content

Support for enforcing single device sign in #2995

Open

Description

@git-boya

Is your feature request related to a problem? Please describe.

When an account logs in, I want the account on other devices to become invalid

** Suggested implementation **

In order to properly support this we would need to add a callback method that is called before the logic in UserAuthentication.signInUser is executed (found here:

)

The behavior of the callback method should be configurable through the authentication configuration defined here:

And the callback should take the userId, session, and method to be useful. It could also be valuable to allow the callback to modify the scopes passed in. But that could be optional.

When that callback is implemented, you could simply sign out that user from all other devices by calling: await session.messages.authenticationRevoked(userId, RevokedAuthenticationUser());. This would remove any existing authentication keys for the user.

Activity

  1. SandPod commented on Nov 28, 2024

    @SandPod
    Contributor

    Hey @git-boya!

    For the Serverpod authentication Module

    In order to properly support this we would need to add a callback method that is called before the logic in UserAuthentication.signInUser is executed (found here:

    )

    The behavior of the callback method should be configurable through the authentication configuration defined here:

    And the callback should take the userId, session, and method to be useful. It could also be valuable to allow the callback to modify the scopes passed in. But that could be optional.

    When that callback is implemented, you could simply sign out that user from all other devices by calling: await session.messages.authenticationRevoked(userId, RevokedAuthenticationUser());. This would remove any existing authentication keys for the user.

    Custom implementation

    Yes, simply call await session.messages.authenticationRevoked(userId, RevokedAuthenticationUser()); before creating your authentication token.

    Implementation

    Is this a feature you would like to request? If so we could update your issue to reflect it?
    If you have the capacity, feel free to take a stab at the implementation as well.

  2. added
    in triage
    on Nov 28, 2024
  3. SandPod commented on Nov 28, 2024

    @SandPod
    Contributor

    This is somewhat related to: #1978

  4. git-boya commented on Nov 28, 2024

    @git-boya
    Author

    Hey @git-boya!

    For the Serverpod authentication Module

    In order to properly support this we would need to add a callback method that is called before the logic in UserAuthentication.signInUser is executed (found here:

    )
    The behavior of the callback method should be configurable through the authentication configuration defined here:

    And the callback should take the userId, session, and method to be useful. It could also be valuable to allow the callback to modify the scopes passed in. But that could be optional.

    When that callback is implemented, you could simply sign out that user from all other devices by calling: await session.messages.authenticationRevoked(userId, RevokedAuthenticationUser());. This would remove any existing authentication keys for the user.

    Custom implementation

    Yes, simply call await session.messages.authenticationRevoked(userId, RevokedAuthenticationUser()); before creating your authentication token.

    Implementation

    Is this a feature you would like to request? If so we could update your issue to reflect it? If you have the capacity, feel free to take a stab at the implementation as well.

    Thank! this is what I want.

  5. changed the title [-]Can single sign on be implemented now?[/-] [+]Support for enforcing single device sign in[/+] on Nov 28, 2024
  6. added
    area: authentication
    and removed
    in triage
    on Nov 28, 2024
  7. moved this to Later 🥳 in Serverpod Frameworkson Nov 28, 2024
  8. added
    enhancement
    on Jan 3, 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