How to use the passport.connect function in passport

To help you get started, we’ve selected a few passport examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pantsel / konga / api / services / Passport.js View on Github external
*
 * As you can see, this function handles both "authentication" and "authori-
 * zation" at the same time. This is due to the fact that we pass in
 * `passReqToCallback: true` when loading the strategies, allowing us to look
 * for an existing session in the request and taking action based on that.
 *
 * For more information on auth(entication|rization) in Passport.js, check out:
 * http://passportjs.org/guide/authenticate/
 * http://passportjs.org/guide/authorize/
 *
 * @param {Request}   request
 * @param {*}         query
 * @param {{}}        profile
 * @param {Function}  next
 */
passport.connect = function connect(request, query, profile, next) {
  sails.log.verbose(__filename + ':' + __line + ' [Service.Passport.connect() called]');

  var user = {};

  // Set the authentication provider.
  query.provider = request.param('provider');

  // If the profile object contains a list of emails, grab the first one and add it to the user.
  if (profile.hasOwnProperty('emails')) {
    user.email = profile.emails[0].value;
  }

  // If the profile object contains a username, add it to the user.
  if (profile.hasOwnProperty('username')) {
    user.username = profile.username;
  }
github kpi-wdc / dj / api / services / passport.js View on Github external
*
 * As you can see, this function handles both "authentication" and "authori-
 * zation" at the same time. This is due to the fact that we pass in
 * `passReqToCallback: true` when loading the strategies, allowing us to look
 * for an existing session in the request and taking action based on that.
 *
 * For more information on auth(entication|rization) in Passport.js, check out:
 * http://passportjs.org/guide/authenticate/
 * http://passportjs.org/guide/authorize/
 *
 * @param {Object}   req
 * @param {Object}   query
 * @param {Object}   profile
 * @param {Function} next
 */
passport.connect = function (req, query, profile, next) {
  var user = {}
    , provider;

  // Get the authentication provider from the query.
  query.provider = req.param('provider');

  // Use profile.provider or fallback to the query.provider if it is undefined
  // as is the case for OpenID, for example
  provider = profile.provider || query.provider;

  // If the provider cannot be identified we cannot match it to a passport so
  // throw an error and let whoever's next in line take care of it.
  if (!provider){
    return next(new Error('No authentication provider was identified.'));
  }
github trailsjs / sails-auth / api / services / passport.js View on Github external
*
   * As you can see, this function handles both "authentication" and "authori-
   * zation" at the same time. This is due to the fact that we pass in
   * `passReqToCallback: true` when loading the strategies, allowing us to look
   * for an existing session in the request and taking action based on that.
   *
   * For more information on auth(entication|rization) in Passport.js, check out:
   * http://passportjs.org/guide/authenticate/
   * http://passportjs.org/guide/authorize/
   *
   * @param {Object}   req
   * @param {Object}   query
   * @param {Object}   profile
   * @param {Function} next
   */
  passport.connect = function (req, query, profile, next) {
    var user = {};

    // Use profile.provider or fallback to the query.provider if it is undefined
    // as is the case for OpenID, for example
    var provider = profile.provider || req.param('provider');

    req.session.tokens = query.tokens;

    // Get the authentication provider from the query.
    query.provider = provider;

    // If the provider cannot be identified we cannot match it to a passport so
    // throw an error and let whoever's next in line take care of it.
    if (!provider) {
      return next(new Error('No authentication provider was identified.'));
    }
github sharepointoscar / MEANS / api / services / passport.js View on Github external
*
 * As you can see, this function handles both "authentication" and "authori-
 * zation" at the same time. This is due to the fact that we pass in
 * `passReqToCallback: true` when loading the strategies, allowing us to look
 * for an existing session in the request and taking action based on that.
 *
 * For more information on auth(entication|rization) in Passport.js, check out:
 * http://passportjs.org/guide/authenticate/
 * http://passportjs.org/guide/authorize/
 *
 * @param {Object}   req
 * @param {Object}   query
 * @param {Object}   profile
 * @param {Function} next
 */
passport.connect = function (req, query, profile, next) {
  var strategies = sails.config.passport
    , config     = strategies[profile.provider]
    , user       = {};

    // Set the authentication provider.
    query.provider = req.param('provider');

    // If the profile object contains a list of emails, grab the first one and
    // add it to the user.
    if (profile.hasOwnProperty('emails')) {
    user.email = profile.emails[0].value;
    }

    // If the profile object contains a username, add it to the user.
    if (profile.hasOwnProperty('username')) {
    user.username = profile.username;
github tarlepp / Taskboard / backend / api / services / Passport.js View on Github external
*
 * As you can see, this function handles both "authentication" and "authori-
 * zation" at the same time. This is due to the fact that we pass in
 * `passReqToCallback: true` when loading the strategies, allowing us to look
 * for an existing session in the request and taking action based on that.
 *
 * For more information on auth(entication|rization) in Passport.js, check out:
 * http://passportjs.org/guide/authenticate/
 * http://passportjs.org/guide/authorize/
 *
 * @param   {Object}    request
 * @param   {Object}    query
 * @param   {Object}    profile
 * @param   {Function}  next
 */
passport.connect = function(request, query, profile, next) {
    var strategies = sails.config.passport;
    var config = strategies[profile.provider];
    var user = {};

    // Set the authentication provider.
    query.provider = request.param('provider');

    // If the profile object contains a list of emails, grab the first one and add it to the user.
    if (profile.hasOwnProperty('emails')) {
        user.email = profile.emails[0].value;
    }

    // If the profile object contains a username, add it to the user.
    if (profile.hasOwnProperty('username')) {
        user.username = profile.username;
    }
github porybox / porybox / api / services / passport.js View on Github external
*
 * As you can see, this function handles both "authentication" and "authori-
 * zation" at the same time. This is due to the fact that we pass in
 * `passReqToCallback: true` when loading the strategies, allowing us to look
 * for an existing session in the request and taking action based on that.
 *
 * For more information on auth(entication|rization) in Passport.js, check out:
 * http://passportjs.org/guide/authenticate/
 * http://passportjs.org/guide/authorize/
 *
 * @param {Object}   req
 * @param {Object}   query
 * @param {Object}   profile
 * @param {Function} next
 */
passport.connect = function (req, query, profile, next) {
  const user = {};

  // Get the authentication provider from the query.
  query.provider = req.param('provider');

  // Use profile.provider or fallback to the query.provider if it is undefined
  // as is the case for OpenID, for example
  const provider = profile.provider || query.provider;

  // If the provider cannot be identified we cannot match it to a passport so
  // throw an error and let whoever's next in line take care of it.
  if (!provider){
    return next(new Error('No authentication provider was identified.'));
  }

  // If the profile object contains a list of emails, grab the first one and
github kasperisager / sails-generate-auth / templates / api / services / passport.js View on Github external
*
 * As you can see, this function handles both "authentication" and "authori-
 * zation" at the same time. This is due to the fact that we pass in
 * `passReqToCallback: true` when loading the strategies, allowing us to look
 * for an existing session in the request and taking action based on that.
 *
 * For more information on auth(entication|rization) in Passport.js, check out:
 * http://passportjs.org/guide/authenticate/
 * http://passportjs.org/guide/authorize/
 *
 * @param {Object}   req
 * @param {Object}   query
 * @param {Object}   profile
 * @param {Function} next
 */
passport.connect = function (req, query, profile, next) {
  var user = {}
    , provider;

  // Get the authentication provider from the query.
  query.provider = req.param('provider');

  // Use profile.provider or fallback to the query.provider if it is undefined
  // as is the case for OpenID, for example
  provider = profile.provider || query.provider;

  // If the provider cannot be identified we cannot match it to a passport so
  // throw an error and let whoever's next in line take care of it.
  if (!provider){
    return next(new Error('No authentication provider was identified.'));
  }
github tilomitra / bedrock / api / services / passport.js View on Github external
*
 * As you can see, this function handles both "authentication" and "authori-
 * zation" at the same time. This is due to the fact that we pass in
 * `passReqToCallback: true` when loading the strategies, allowing us to look
 * for an existing session in the request and taking action based on that.
 *
 * For more information on auth(entication|rization) in Passport.js, check out:
 * http://passportjs.org/guide/authenticate/
 * http://passportjs.org/guide/authorize/
 *
 * @param {Object}   req
 * @param {Object}   query
 * @param {Object}   profile
 * @param {Function} next
 */
passport.connect = function (req, query, profile, next) {
  var user = {}
    , provider;

  // Get the authentication provider from the query.
  query.provider = req.param('provider');

  // Use profile.provider or fallback to the query.provider if it is undefined
  // as is the case for OpenID, for example
  provider = profile.provider || query.provider;

  // If the provider cannot be identified we cannot match it to a passport so
  // throw an error and let whoever's next in line take care of it.
  if (!provider){
    return next(new Error('No authentication provider was identified.'));
  }
github ryancp / sailng / api / services / passport.js View on Github external
*
 * As you can see, this function handles both "authentication" and "authori-
 * zation" at the same time. This is due to the fact that we pass in
 * `passReqToCallback: true` when loading the strategies, allowing us to look
 * for an existing session in the request and taking action based on that.
 *
 * For more information on auth(entication|rization) in Passport.js, check out:
 * http://passportjs.org/guide/authenticate/
 * http://passportjs.org/guide/authorize/
 *
 * @param {Object}   req
 * @param {Object}   query
 * @param {Object}   profile
 * @param {Function} next
 */
passport.connect = function (req, query, profile, next) {
  var user = {}
    , provider;

  // Get the authentication provider from the query.
  query.provider = req.param('provider');

  // Use profile.provider or fallback to the query.provider if it is undefined
  // as is the case for OpenID, for example
  provider = profile.provider || query.provider;

  // If the provider cannot be identified we cannot match it to a passport so
  // throw an error and let whoever's next in line take care of it.
  if (!provider){
    return next(new Error('No authentication provider was identified.'));
  }