How to use the passport.endpoint 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 trailsjs / sails-auth / api / services / passport.js View on Github external
}
        }
      })
      .catch(next);
  };

  /**
   * Create an authentication endpoint
   *
   * For more information on authentication in Passport.js, check out:
   * http://passportjs.org/guide/authenticate/
   *
   * @param  {Object} req
   * @param  {Object} res
   */
  passport.endpoint = function (req, res) {
    var strategies = sails.config.passport;
    var provider = req.param('provider');
    var options = {};

    // If a provider doesn't exist for this endpoint, send the user back to the
    // login page
    if (!_.has(strategies, provider)) {
      return res.redirect('/login');
    }

    // Attach scope if it has been set in the config
    if (_.has(strategies[provider], 'scope')) {
      options.scope = strategies[provider].scope;
    }

    // Redirect the user to the provider for authentication. When complete,
github pantsel / konga / api / services / Passport.js View on Github external
}
        }
      });
  }
};

/**
 * Create an authentication endpoint
 *
 * For more information on authentication in Passport.js, check out:
 * http://passportjs.org/guide/authenticate/
 *
 * @param {Request}   request
 * @param {Response}  response
 */
passport.endpoint = function endpoint(request, response) {
  sails.log.verbose(__filename + ':' + __line + ' [Service.Passport.endpoint() called]');

  var strategies = sails.config.passport;
  var provider = request.param('provider');
  var options = {};

  // If a provider doesn't exist for this endpoint, send the user back to the login page
  if (!strategies.hasOwnProperty(provider)) {
    response.json(401, 'Unknown auth provider');
  } else {
    // Attach scope if it has been set in the config
    if (strategies[provider].hasOwnProperty('scope')) {
      options.scope = strategies[provider].scope;
    }

    // Load authentication strategies
github tarlepp / Taskboard / backend / api / services / Passport.js View on Github external
}
                }
            });
    }
};

/**
 * Create an authentication endpoint
 *
 * For more information on authentication in Passport.js, check out:
 * http://passportjs.org/guide/authenticate/
 *
 * @param   {Object}    request
 * @param   {Object}    response
 */
passport.endpoint = function(request, response) {
    var strategies = sails.config.passport;
    var provider = request.param('provider');
    var options = {};

    // If a provider doesn't exist for this endpoint, send the user back to the login page
    if (!strategies.hasOwnProperty(provider)) {
        response.json(401, 'Unknown auth provider');
    } else {
        // Attach scope if it has been set in the config
        if (strategies[provider].hasOwnProperty('scope')) {
            options.scope = strategies[provider].scope;
        }

        // Load authentication strategies
        this.loadStrategies(request);
github ryancp / sailng / api / services / passport.js View on Github external
next(null, req.user);
      }
    }
  });
};

/**
 * Create an authentication endpoint
 *
 * For more information on authentication in Passport.js, check out:
 * http://passportjs.org/guide/authenticate/
 *
 * @param  {Object} req
 * @param  {Object} res
 */
passport.endpoint = function (req, res) {
  var strategies = sails.config.passport
    , provider   = req.param('provider')
    , options    = {};

  // If a provider doesn't exist for this endpoint, send the user back to the
  // login page
  if (!strategies.hasOwnProperty(provider)) {
    return res.redirect('/login');
  }

  // Attach scope if it has been set in the config
  if (strategies[provider].hasOwnProperty('scope')) {
    options.scope = strategies[provider].scope;
  }

  // Redirect the user to the provider for authentication. When complete,
github tilomitra / bedrock / api / services / passport.js View on Github external
next(null, req.user);
      }
    }
  });
};

/**
 * Create an authentication endpoint
 *
 * For more information on authentication in Passport.js, check out:
 * http://passportjs.org/guide/authenticate/
 *
 * @param  {Object} req
 * @param  {Object} res
 */
passport.endpoint = function (req, res) {
  var strategies = sails.config.passport
    , provider   = req.param('provider')
    , options    = {};

  // If a provider doesn't exist for this endpoint, send the user back to the
  // login page
  if (!strategies.hasOwnProperty(provider)) {
    return res.redirect('/login');
  }

  // Attach scope if it has been set in the config
  if (strategies[provider].hasOwnProperty('scope')) {
    options.scope = strategies[provider].scope;
  }

  // Redirect the user to the provider for authentication. When complete,
github sharepointoscar / MEANS / api / services / passport.js View on Github external
next(null, req.user);
      }
    }
  });
};

/**
 * Create an authentication endpoint
 *
 * For more information on authentication in Passport.js, check out:
 * http://passportjs.org/guide/authenticate/
 *
 * @param  {Object} req
 * @param  {Object} res
 */
passport.endpoint = function (req, res) {
  var strategies = sails.config.passport
    , provider   = req.param('provider')
    , options    = {};

  // If a provider doesn't exist for this endpoint, send the user back to the
  // login page
  if (!strategies.hasOwnProperty(provider)) {
    return res.redirect('/login');
  }

  // Attach scope if it has been set in the config
  if (strategies[provider].hasOwnProperty('scope')) {
    options.scope = strategies[provider].scope;
  }

  // Load authentication strategies
github porybox / porybox / api / services / passport.js View on Github external
next(null, req.user);
      }
    }
  });
};

/**
 * Create an authentication endpoint
 *
 * For more information on authentication in Passport.js, check out:
 * http://passportjs.org/guide/authenticate/
 *
 * @param  {Object} req
 * @param  {Object} res
 */
passport.endpoint = function (req, res) {
  const strategies = sails.config.passport,
    provider   = req.param('provider'),
    options    = {};

  // If a provider doesn't exist for this endpoint, send the user back to the
  // login page
  if (!strategies.hasOwnProperty(provider)) {
    return res.redirect('/login');
  }

  // Attach scope if it has been set in the config
  if (strategies[provider].hasOwnProperty('scope')) {
    options.scope = strategies[provider].scope;
  }

  // Redirect the user to the provider for authentication. When complete,
github kasperisager / sails-generate-auth / templates / api / services / passport.js View on Github external
next(null, req.user);
      }
    }
  });
};

/**
 * Create an authentication endpoint
 *
 * For more information on authentication in Passport.js, check out:
 * http://passportjs.org/guide/authenticate/
 *
 * @param  {Object} req
 * @param  {Object} res
 */
passport.endpoint = function (req, res) {
  var strategies = sails.config.passport
    , provider   = req.param('provider')
    , options    = {};

  // If a provider doesn't exist for this endpoint, send the user back to the
  // login page
  if (!strategies.hasOwnProperty(provider)) {
    return res.redirect('/login');
  }

  // Attach scope if it has been set in the config
  if (strategies[provider].hasOwnProperty('scope')) {
    options.scope = strategies[provider].scope;
  }

  // Redirect the user to the provider for authentication. When complete,
github kpi-wdc / dj / api / services / passport.js View on Github external
next(null, req.user);
      }
    }
  });
};

/**
 * Create an authentication endpoint
 *
 * For more information on authentication in Passport.js, check out:
 * http://passportjs.org/guide/authenticate/
 *
 * @param  {Object} req
 * @param  {Object} res
 */
passport.endpoint = function (req, res) {
  var strategies = sails.config.passport
    , provider   = req.param('provider')
    , options    = {};

  // If a provider doesn't exist for this endpoint, send the user back to the
  // login page
  if (!strategies.hasOwnProperty(provider)) {
    return res.redirect('/login');
  }

  // Attach scope if it has been set in the config
  if (strategies[provider].hasOwnProperty('scope')) {
    options.scope = strategies[provider].scope;
  }

  // Redirect the user to the provider for authentication. When complete,