Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
* The former sets up an endpoint (/auth/:provider) for redirecting a user to a
* third-party provider for authentication, while the latter sets up a callback
* endpoint (/auth/:provider/callback) for receiving the response from the
* third-party provider. All you have to do is define in the configuration which
* third-party providers you'd like to support. It's that easy!
*
* Behind the scenes, the service stores all the data it needs within "Passports".
* These contain all the information required to associate a local user with a
* profile from a third-party provider. This even holds true for the good ol'
* password authentication scheme – the Authentication Service takes care of
* encrypting passwords and storing them in Passports, allowing you to keep your
* User model free of bloat.
*/
// Load authentication protocols
passport.protocols = require('./protocols');
/**
* Connect a third-party profile to a local user
*
* This is where most of the magic happens when a user is authenticating with a
* third-party provider. What it does, is the following:
*
* 1. Given a provider and an identifier, find a matching Passport.
* 2. From here, the logic branches into two paths.
*
* - A user is not currently logged in:
* 1. If a Passport wasn't found, just return 401
* 2. If a Passport was found, get the user associated with the passport.
*
* - A user is currently logged in:
* 1. If a Passport wasn't found, just return 401
* Behind the scenes, the service stores all the data it needs within "Passports".
* These contain all the information required to associate a local user with a
* profile from a third-party provider. This even holds true for the good ol'
* password authentication scheme – the Authentication Service takes care of
* encrypting passwords and storing them in Passports, allowing you to keep your
* User model free of bloat.
*/
// Module dependencies
var passport = require('passport');
var path = require('path');
var url = require('url');
var _ = require('lodash');
// Load authentication protocols
passport.protocols = require('./protocols');
/**
* Connect a third-party profile to a local user
*
* This is where most of the magic happens when a user is authenticating with a
* third-party provider. What it does, is the following:
*
* 1. Given a provider and an identifier, find a matching Passport.
* 2. From here, the logic branches into two paths.
*
* - A user is not currently logged in:
* 1. If a Passport wasn't found, just return 401
* 2. If a Passport was found, get the user associated with the passport.
*
* - A user is currently logged in:
* 1. If a Passport wasn't found, just return 401
* The former sets up an endpoint (/auth/:provider) for redirecting a user to a
* third-party provider for authentication, while the latter sets up a callback
* endpoint (/auth/:provider/callback) for receiving the response from the
* third-party provider. All you have to do is define in the configuration which
* third-party providers you'd like to support. It's that easy!
*
* Behind the scenes, the service stores all the data it needs within "Pass-
* ports". These contain all the information required to associate a local user
* with a profile from a third-party provider. This even holds true for the good
* ol' password authentication scheme – the Authentication Service takes care of
* encrypting passwords and storing them in Passports, allowing you to keep your
* User model free of bloat.
*/
// Load authentication protocols
passport.protocols = require('./protocols');
/**
* Connect a third-party profile to a local user
*
* This is where most of the magic happens when a user is authenticating with a
* third-party provider. What it does, is the following:
*
* 1. Given a provider and an identifier, find a matching Passport.
* 2. From here, the logic branches into two paths.
*
* - A user is not currently logged in:
* 1. If a Passport wasn't found, create a new user as well as a new
* Passport that will be assigned to the user.
* 2. If a Passport was found, get the user associated with the passport.
*
* - A user is currently logged in:
* The former sets up an endpoint (/auth/:provider) for redirecting a user to a
* third-party provider for authentication, while the latter sets up a callback
* endpoint (/auth/:provider/callback) for receiving the response from the
* third-party provider. All you have to do is define in the configuration which
* third-party providers you'd like to support. It's that easy!
*
* Behind the scenes, the service stores all the data it needs within "Pass-
* ports". These contain all the information required to associate a local user
* with a profile from a third-party provider. This even holds true for the good
* ol' password authentication scheme – the Authentication Service takes care of
* encrypting passwords and storing them in Passports, allowing you to keep your
* User model free of bloat.
*/
// Load authentication protocols
passport.protocols = require('./protocols');
/**
* Connect a third-party profile to a local user
*
* This is where most of the magic happens when a user is authenticating with a
* third-party provider. What it does, is the following:
*
* 1. Given a provider and an identifier, find a mathcing Passport.
* 2. From here, the logic branches into two paths.
*
* - A user is not currently logged in:
* 1. If a Passport wassn't found, create a new user as well as a new
* Passport that will be assigned to the user.
* 2. If a Passport was found, get the user associated with the passport.
*
* - A user is currently logged in:
* The former sets up an endpoint (/auth/:provider) for redirecting a user to a
* third-party provider for authentication, while the latter sets up a callback
* endpoint (/auth/:provider/callback) for receiving the response from the
* third-party provider. All you have to do is define in the configuration which
* third-party providers you'd like to support. It's that easy!
*
* Behind the scenes, the service stores all the data it needs within "Pass-
* ports". These contain all the information required to associate a local user
* with a profile from a third-party provider. This even holds true for the good
* ol' password authentication scheme – the Authentication Service takes care of
* encrypting passwords and storing them in Passports, allowing you to keep your
* User model free of bloat.
*/
// Load authentication protocols
passport.protocols = require('./protocols');
/**
* Connect a third-party profile to a local user
*
* This is where most of the magic happens when a user is authenticating with a
* third-party provider. What it does, is the following:
*
* 1. Given a provider and an identifier, find a matching Passport.
* 2. From here, the logic branches into two paths.
*
* - A user is not currently logged in:
* 1. If a Passport wasn't found, create a new user as well as a new
* Passport that will be assigned to the user.
* 2. If a Passport was found, get the user associated with the passport.
*
* - A user is currently logged in:
* The former sets up an endpoint (/auth/:provider) for redirecting a user to a
* third-party provider for authentication, while the latter sets up a callback
* endpoint (/auth/:provider/callback) for receiving the response from the
* third-party provider. All you have to do is define in the configuration which
* third-party providers you'd like to support. It's that easy!
*
* Behind the scenes, the service stores all the data it needs within "Pass-
* ports". These contain all the information required to associate a local user
* with a profile from a third-party provider. This even holds true for the good
* ol' password authentication scheme – the Authentication Service takes care of
* encrypting passwords and storing them in Passports, allowing you to keep your
* User model free of bloat.
*/
// Load authentication protocols
passport.protocols = require('./protocols');
/**
* Connect a third-party profile to a local user
*
* This is where most of the magic happens when a user is authenticating with a
* third-party provider. What it does, is the following:
*
* 1. Given a provider and an identifier, find a matching Passport.
* 2. From here, the logic branches into two paths.
*
* - A user is not currently logged in:
* 1. If a Passport wassn't found, create a new user as well as a new
* Passport that will be assigned to the user.
* 2. If a Passport was found, get the user associated with the passport.
*
* - A user is currently logged in:
* The former sets up an endpoint (/auth/:provider) for redirecting a user to a
* third-party provider for authentication, while the latter sets up a callback
* endpoint (/auth/:provider/callback) for receiving the response from the
* third-party provider. All you have to do is define in the configuration which
* third-party providers you'd like to support. It's that easy!
*
* Behind the scenes, the service stores all the data it needs within "Pass-
* ports". These contain all the information required to associate a local user
* with a profile from a third-party provider. This even holds true for the good
* ol' password authentication scheme – the Authentication Service takes care of
* encrypting passwords and storing them in Passports, allowing you to keep your
* User model free of bloat.
*/
// Load authentication protocols
passport.protocols = require('./protocols');
/**
* Connect a third-party profile to a local user
*
* This is where most of the magic happens when a user is authenticating with a
* third-party provider. What it does, is the following:
*
* 1. Given a provider and an identifier, find a matching Passport.
* 2. From here, the logic branches into two paths.
*
* - A user is not currently logged in:
* 1. If a Passport wasn't found, create a new user as well as a new
* Passport that will be assigned to the user.
* 2. If a Passport was found, get the user associated with the passport.
*
* - A user is currently logged in:
* The former sets up an endpoint (/auth/:provider) for redirecting a user to a
* third-party provider for authentication, while the latter sets up a callback
* endpoint (/auth/:provider/callback) for receiving the response from the
* third-party provider. All you have to do is define in the configuration which
* third-party providers you'd like to support. It's that easy!
*
* Behind the scenes, the service stores all the data it needs within "Pass-
* ports". These contain all the information required to associate a local user
* with a profile from a third-party provider. This even holds true for the good
* ol' password authentication scheme – the Authentication Service takes care of
* encrypting passwords and storing them in Passports, allowing you to keep your
* User model free of bloat.
*/
// Load authentication protocols
passport.protocols = require('./protocols');
/**
* Connect a third-party profile to a local user
*
* This is where most of the magic happens when a user is authenticating with a
* third-party provider. What it does, is the following:
*
* 1. Given a provider and an identifier, find a matching Passport.
* 2. From here, the logic branches into two paths.
*
* - A user is not currently logged in:
* 1. If a Passport wasn't found, create a new user as well as a new
* Passport that will be assigned to the user.
* 2. If a Passport was found, get the user associated with the passport.
*
* - A user is currently logged in:
* The former sets up an endpoint (/auth/:provider) for redirecting a user to a
* third-party provider for authentication, while the latter sets up a callback
* endpoint (/auth/:provider/callback) for receiving the response from the
* third-party provider. All you have to do is define in the configuration which
* third-party providers you'd like to support. It's that easy!
*
* Behind the scenes, the service stores all the data it needs within "Pass-
* ports". These contain all the information required to associate a local user
* with a profile from a third-party provider. This even holds true for the good
* ol' password authentication scheme – the Authentication Service takes care of
* encrypting passwords and storing them in Passports, allowing you to keep your
* User model free of bloat.
*/
// Load authentication protocols
passport.protocols = require('./protocols');
/**
* Connect a third-party profile to a local user
*
* This is where most of the magic happens when a user is authenticating with a
* third-party provider. What it does, is the following:
*
* 1. Given a provider and an identifier, find a mathcing Passport.
* 2. From here, the logic branches into two paths.
*
* - A user is not currently logged in:
* 1. If a Passport wassn't found, create a new user as well as a new
* Passport that will be assigned to the user.
* 2. If a Passport was found, get the user associated with the passport.
*
* - A user is currently logged in: