jaredhanson / jaredhanson/passport

Strategies does not scale well

Open
#613 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
23.5k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

In case of multiple node services, scaled horizontally, passport `use` (which register a Strategy by name) and `authenticate` (which get back a Strategy previously registered by name) do not scale well because all the nodes would not shared the same private `_strategies` *store* object.

You can have one request initiated on a node but ended on another node for the sso callback when having load balancing and those can have different Strategy configuration for the same name. This can happen when you update your Strategies configuration but restart your node one by one for a high quality of service.

A better way to handle this is to recreate the Strategy for each request and never rely on a *store* object (so no cache), but the `authenticate` method get in the way because it only rely on the `_strategies` internal *store* See https://github.com/jaredhanson/passport/blob/master/lib/authenticator.js#L463

Contributor guide

Open the contributing guide

Research direction

Start with lib/authenticator.js around authenticate and the _strategies store, then compare how use registers strategies by name. Determine how request-time strategy recreation could work without relying on the shared store, and define completion around consistent strategy configuration across load-balanced nodes during rolling restarts.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
authentication, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.