Skip to content

How to use in clustered node server (PM2)? #123

Open
@ysageev

Description

I'm struggling trying to implement OAuth2 in a pm2 clustered environment. The example provided stores the new OAuthClient in a global variable. This is great if everyone is connecting to that one server instance. In production that is almost never the case.

I am going to assume that if process 1 and process 2 create wholly new OAuthClients, then access tokens returned to 2 will invalidate tokens in 1. Is that correct?

If so, I need a way to reconstitute an OAuthClient from data stored in a database. I imagine the flow will look like this:

  1. On connect request, check global variable is populated.
  2. If not, grab the access and refresh tokens and expiry from the database
  3. Recreate OAuthClient and manually and enter data from (2). HOW?
  4. If access token has expired, call RefreshToken() etc. ...

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions