Skip to content

Password Grant - allow multiple sessions per user #32

@michaelhogguk

Description

@michaelhogguk

Firstly I wanted to thank you for your awesome library @alexbilbie :)

For the Password Grant, why are existing sessions deleted when the new session is created?

public function completeFlow($inputParams = null)
{
    ...
    // Delete any existing sessions just to be sure
    $this->authServer->getStorage('session')->deleteSession($authParams['client_id'], 'user', $userId);

    // Create a new session
    $sessionId = $this->authServer->getStorage('session')->createSession(
    ...
}

The Password Grant is often used for first-party "official" mobile apps. A user may wish to install such an app on two devices (eg: an iPhone and an iPod touch) and stay signed in on both of them.

With the existing functionality in the Password Grant, when the user signs in on their second device, deleteSession() will delete their first session from the oauth_sessions table, effectively signing them out from their first device.

If the call to deleteSession() was removed, then oauth_sessions could contain an unlimited number of sessions per user, enabling a user to stay signed in on an unlimited number of devices. Sessions can be deleted from oauth_sessions when:

  • The session doesn't have a refresh token, and the current time passes access_token_expires, or
  • The session does have a refresh token, and a very large amount of time (eg: a year) has passed since access_token_expires (it's very unlikely that the refresh token will be used a year after the access token has expired).

This is similar to Issue #25. The difference is:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions