Skip to content

Latest commit

 

History

History

OAuth Strategies

The currently supported OAuth strategies are:

Microsoft and Twitter strategies are custom ones because no currently available passport strategies were able to perform a working auth or profile retrieving process.

Add your own strategy

  1. Create your strategy
  2. Call yggdrasil.repositories.auth.addOAuthStrategy('strategyName', new strategyClass());

Create your strategy

Passport is made to be used directly with Express, and the authorize method have to be called on each and every route. As Yggdrasil uses its own auth system (based on JWT, based on express-jwt and socketio-jwt), we need to use a custom way to call the passport strategies.

To do so, there is an abstraction layer, performed by the OAuthStrategy class, that allow you to use officials passport strategies or custom ones without a headache.

To create your own OAuth strategy, have a look at the Google strategy.

The process is quite simple :

  1. import the OAuthStrategy class
  2. import the passport strategy you want to use
  3. create a class which extends the OAuthStrategy class
  4. put your strategy configuration into your custom config file (ig .yggdrasilrc)

Once this is done, you can call yggdrasil.repositories.auth.addOAuthStrategy('strategyName', new strategyClass());