How to use the passport/lib.use 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 OpenCTI-Platform / opencti / opencti-platform / opencti-graphql / src / config / security.js View on Github external
callbackURL: conf.get('providers:github:callback_uri'),
    scope: 'user:email'
  };
  const githubStrategy = new GithubStrategy(githubOptions, (token, tokenSecret, profile, done) => {
    const { name } = profile;
    const email = head(profile.emails).value;
    // let picture = profile.avatar_url;
    loginFromProvider(email, name)
      .then(loggedToken => {
        done(null, loggedToken);
      })
      .catch(err => {
        done(err);
      });
  });
  passport.use(githubStrategy);
  providers.push('github');
}

export const ACCESS_PROVIDERS = join(',', providers);
export default passport;
github OpenCTI-Platform / opencti / opencti-platform / opencti-graphql / src / config / security.js View on Github external
scope: 'email'
  };
  const facebookStrategy = new FacebookStrategy(facebookOptions, (accessToken, refreshToken, profile, done) => {
    // eslint-disable-next-line no-underscore-dangle
    const data = profile._json;
    const name = `${data.last_name} ${data.first_name}`;
    const { email } = data;
    loginFromProvider(email, name)
      .then(token => {
        done(null, token);
      })
      .catch(err => {
        done(err);
      });
  });
  passport.use(facebookStrategy);
  providers.push('facebook');
}
// Google
if (conf.get('providers:google')) {
  const googleOptions = {
    clientID: conf.get('providers:google:client_id'),
    clientSecret: conf.get('providers:google:client_secret'),
    callbackURL: conf.get('providers:google:callback_uri'),
    scope: 'email'
  };
  const googleStrategy = new GoogleStrategy(googleOptions, (token, tokenSecret, profile, done) => {
    const name = profile.displayName;
    const email = head(profile.emails).value;
    // let picture = head(profile.photos).value;
    loginFromProvider(email, name)
      .then(loggedToken => {
github OpenCTI-Platform / opencti / opencti-graphql / src / config / security.js View on Github external
const githubStrategy = new GithubStrategy(
    githubOptions,
    (token, tokenSecret, profile, done) => {
      const { name } = profile;
      const email = head(profile.emails).value;
      // let picture = profile.avatar_url;
      loginFromProvider(email, name)
        .then(loggedToken => {
          done(null, loggedToken);
        })
        .catch(err => {
          done(err);
        });
    }
  );
  passport.use(githubStrategy);
  providers.push('github');
}

export const ACCESS_PROVIDERS = join(',', providers);
export default passport;
github OpenCTI-Platform / opencti / opencti-graphql / src / config / security.js View on Github external
const googleStrategy = new GoogleStrategy(
    googleOptions,
    (token, tokenSecret, profile, done) => {
      const name = profile.displayName;
      const email = head(profile.emails).value;
      // let picture = head(profile.photos).value;
      loginFromProvider(email, name)
        .then(loggedToken => {
          done(null, loggedToken);
        })
        .catch(err => {
          done(err);
        });
    }
  );
  passport.use(googleStrategy);
  providers.push('google');
}
// Github
if (conf.get('providers:github')) {
  const githubOptions = {
    clientID: conf.get('providers:github:client_id'),
    clientSecret: conf.get('providers:github:client_secret'),
    callbackURL: conf.get('providers:github:callback_uri'),
    scope: 'user:email'
  };
  const githubStrategy = new GithubStrategy(
    githubOptions,
    (token, tokenSecret, profile, done) => {
      const { name } = profile;
      const email = head(profile.emails).value;
      // let picture = profile.avatar_url;
github OpenCTI-Platform / opencti / opencti-platform / opencti-graphql / src / config / security.js View on Github external
callbackURL: conf.get('providers:google:callback_uri'),
    scope: 'email'
  };
  const googleStrategy = new GoogleStrategy(googleOptions, (token, tokenSecret, profile, done) => {
    const name = profile.displayName;
    const email = head(profile.emails).value;
    // let picture = head(profile.photos).value;
    loginFromProvider(email, name)
      .then(loggedToken => {
        done(null, loggedToken);
      })
      .catch(err => {
        done(err);
      });
  });
  passport.use(googleStrategy);
  providers.push('google');
}
// Github
if (conf.get('providers:github')) {
  const githubOptions = {
    clientID: conf.get('providers:github:client_id'),
    clientSecret: conf.get('providers:github:client_secret'),
    callbackURL: conf.get('providers:github:callback_uri'),
    scope: 'user:email'
  };
  const githubStrategy = new GithubStrategy(githubOptions, (token, tokenSecret, profile, done) => {
    const { name } = profile;
    const email = head(profile.emails).value;
    // let picture = profile.avatar_url;
    loginFromProvider(email, name)
      .then(loggedToken => {
github OpenCTI-Platform / opencti / opencti-graphql / src / config / security.js View on Github external
facebookOptions,
    (accessToken, refreshToken, profile, done) => {
      // eslint-disable-next-line no-underscore-dangle
      const data = profile._json; // TODO CHECK THAT
      const name = `${data.last_name} ${data.first_name}`;
      const { email } = data;
      loginFromProvider(email, name)
        .then(token => {
          done(null, token);
        })
        .catch(err => {
          done(err);
        });
    }
  );
  passport.use(facebookStrategy);
  providers.push('facebook');
}
// Google
if (conf.get('providers:google')) {
  const googleOptions = {
    clientID: conf.get('providers:google:client_id'),
    clientSecret: conf.get('providers:google:client_secret'),
    callbackURL: conf.get('providers:google:callback_uri'),
    scope: 'email'
  };
  const googleStrategy = new GoogleStrategy(
    googleOptions,
    (token, tokenSecret, profile, done) => {
      const name = profile.displayName;
      const email = head(profile.emails).value;
      // let picture = head(profile.photos).value;