How to use the passport._strategies 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 martijnboland / appoints-api-node / routehandlers / auth.js View on Github external
exports.facebooktoken = function (req, res) {
  // NOTE: this (ab)uses the passport strategy-specific userProfile method to check if a token is valid.
  var fbStrategy = passport._strategies.facebook;
  fbStrategy.userProfile(req.body.token, function (err, profile) {
    if (err) {
      return sendTokenValidationError(res, err);
    }
    var user = createUserFromProfile(profile);
    sendLoggedInResponseForUser(user, res);
  });
}
github martijnboland / appoints-api-node / routehandlers / auth.js View on Github external
exports.googletoken = function (req, res) {
  // NOTE: this (ab)uses the passport strategy-specific userProfile method to check if a token is valid.
  var googleStrategy = passport._strategies.google;
  googleStrategy.userProfile(req.body.token, function (err, profile) {
    if (err) {
      return sendTokenValidationError(res, err);
    }
    var user = createUserFromProfile(profile);
    sendLoggedInResponseForUser(user, res);
  });
}
github TheFive / osmbc / test / testutil.js View on Github external
function fakeNextPassportLogin(userString) {
  passport._strategies.openstreetmap._token_response = {
    access_token: "at-1234",
    expires_in: 3600
  };

  passport._strategies.openstreetmap._profile = {
    displayName: userString
  };
}
github projectSHAI / GOATstack / config / env / production / systemjs.server.js View on Github external
}));

System.set('chalk', System.newModule({
  bold: require('chalk').bold
}));

System.set('path', System.newModule({
  resolve: require('path').resolve
}));

System.set('passport', System.newModule({
  use: passport.use,
  authenticate: passport.authenticate,
  initialize: passport.initialize,

  _strategies: passport._strategies,
  _strategy: passport._strategy,
  _framework: passport._framework
}));

System.set('passport-local', System.newModule({
  Strategy: require('passport-local').Strategy
}));
github TryGhost / Ghost / core / server / auth / ghost-auth.js View on Github external
module.exports.getUser = function getUser(options) {
    options = options || {};

    var id = options.id,
        ghostOAuth2Strategy = passport._strategies.ghost;

    return new Promise(function (resolve, reject) {
        ghostOAuth2Strategy.userProfileByIdentityId(id, function (err, profile) {
            if (err) {
                return reject(err);
            }

            resolve(profile);
        });
    });
};
github ghaiklor / generator-sails-rest-api / generators / authentication / templates / api / controllers / AuthController.js View on Github external
social(req, res) {
    const type = req.param('type') ? req.param('type').toLowerCase() : '-';
    const strategyName = [type, 'token'].join('-');

    if (Object.keys(passport._strategies).indexOf(strategyName) === -1) {
      return res.badRequest(null, {message: [type, ' is not supported'].join('')});
    }

    passport.authenticate('jwt', (error, user, info) => {
      req.user = user;
      passport.authenticate(strategyName, _.partial(sails.config.passport.onPassportAuth, req, res))(req, res);
    })(req, res);
  },
github EdgeVerve / oe-cloud / server / middleware / jwt-assertion.js View on Github external
return function jwtAssertionPassportAuthenticateCb(req, res, next) {
    var proxyKey = app.get('evproxyInternalKey') || '97b62fa8-2a77-458b-87dd-ef64ff67f847';
    if (req.headers && proxyKey) {
      if (req.headers['x-evproxy-internal-key'] === proxyKey) {
        return next();
      }
    }
    if (process.env.SECRET_OR_KEY && process.env.SECRET_OR_KEY.length > 0) {
      Passport._strategies.jwt._secretOrKey = jwtUtil.sanitizePublicKey(process.env.SECRET_OR_KEY);
    }
    Passport.authenticate('jwt', (err, user, info) => {
      if (err) {
        return next(err);
      }
      if (!user) {
        return next();
      }

      if (user) {
        var trustedApp = user[jwtConfig.keyToVerify];
        var userObj = loopback.getModelByType('BaseUser');
        var username = '';
        if (trustedApp) {
          var rolesToAdd = [];
          var appObj = loopback.getModelByType('TrustedApp');