How to use passport-auth0 - 5 common examples

To help you get started, we’ve selected a few passport-auth0 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 cassioscabral / rateissuesfront / src / core / passport.js View on Github external
{model: UserLogin, as: 'logins'},
      {model: UserClaim, as: 'claims'},
      {model: UserProfile, as: 'profile'}
    ]
  })
}

/**
 * Sign in with auth0.
 */
let callbackURL = '/login/auth0/return'
if (process.env.NODE_ENV === 'development') {
 callbackURL = 'http://localhost:3001/login/auth0/return'
}

passport.use(new Auth0Strategy({
  domain: env.auth0.CLIENT_DOMAIN,
  clientID: env.auth0.CLIENT_ID,
  clientSecret: env.auth0.CLIENT_SECRET,
  callbackURL,
  profileFields: ['name', 'email', 'link', 'locale', 'timezone'],
  passReqToCallback: true
}, (req, accessToken, refreshToken, profile, done) => {
  /* eslint-disable no-underscore-dangle */
  const authenticate = async () => {
    let user = null
    let userToken = {}

    // req.user recived from jwt cookie's token
    if (req.user) {
      user = await UserLogin.findOne({
        attributes: ['name', 'key'],
github amaurymartiny / timed / app / server / app.js View on Github external
var app = express();

//
// Set up graphql server
// -----------------------------------------------------------------------------
app.use('/graphql', graphqlHTTP(req => ({
  schema,
  graphiql: true,
  pretty: true
})));

//
// Authentication
// -----------------------------------------------------------------------------
var strategy = new Auth0Strategy({
    domain:       process.env.AUTH0_DOMAIN,
    clientID:     process.env.AUTH0_CLIENT_ID,
    clientSecret: process.env.AUTH0_CLIENT_SECRET,
    callbackURL:  process.env.AUTH0_CALLBACK_URL || 'http://localhost:3000/callback'
  }, function(accessToken, refreshToken, extraParams, profile, done) {
    // accessToken is the token to call Auth0 API (not needed in the most cases)
    // extraParams.id_token has the JSON Web Token
    // profile has all the information from the user
    return done(null, profile);
  });

passport.use(strategy);

// you can use this section to keep a smaller payload
passport.serializeUser(function(user, done) {
  done(null, user);
github MoveOnOrg / Spoke / src / server / auth-passport.js View on Github external
export function setupAuth0Passport() {
  const strategy = new Auth0Strategy(
    {
      domain: process.env.AUTH0_DOMAIN,
      clientID: process.env.AUTH0_CLIENT_ID,
      clientSecret: process.env.AUTH0_CLIENT_SECRET,
      callbackURL: `${process.env.BASE_URL}/login-callback`
    },
    (accessToken, refreshToken, extraParams, profile, done) =>
      done(null, profile)
  );

  passport.use(strategy);

  passport.serializeUser((user, done) => {
    // This is the Auth0 user object, not the db one
    // eslint-disable-next-line no-underscore-dangle
    const auth0Id = user.id || user._json.sub;
github MoveOnOrg / Spoke / src / server / setup-auth0-passport.js View on Github external
function setupAuth0Passport() {
  const strategy = new Auth0Strategy({
    domain: process.env.AUTH0_DOMAIN,
    clientID: process.env.AUTH0_CLIENT_ID,
    clientSecret: process.env.AUTH0_CLIENT_SECRET,
    callbackURL: process.env.AUTH0_LOGIN_CALLBACK
  }, (accessToken, refreshToken, extraParams, profile, done) => done(null, profile)
  )

  passport.use(strategy)

  passport.serializeUser((user, done) => {
    const auth0Id = (user.id || user._json.sub)
    done(null, auth0Id)
  })

  passport.deserializeUser(wrap(async (id, done) => {
    const user = await User.filter({ auth0_id: id })
github mozilla / voice-web / server / src / auth-router.ts View on Github external
}),
    proxy: true,
    resave: false,
    saveUninitialized: false,
  })
);
router.use(passport.initialize());
router.use(passport.session());

passport.serializeUser((user: any, done: Function) => done(null, user));
passport.deserializeUser((sessionUser: any, done: Function) =>
  done(null, sessionUser)
);

if (DOMAIN) {
  Auth0Strategy.prototype.authorizationParams = function(options: any) {
    var options = options || {};

    const params: any = {};
    if (options.connection && typeof options.connection === 'string') {
      params.connection = options.connection;
    }
    if (options.audience && typeof options.audience === 'string') {
      params.audience = options.audience;
    }
    params.account_verification = true;

    return params;
  };

  const strategy = new Auth0Strategy(
    {

passport-auth0

Auth0 platform authentication strategy for Passport.js

MIT
Latest version published 1 year ago

Package Health Score

68 / 100
Full package analysis

Popular passport-auth0 functions