How to use the passport-auth0 function in passport-auth0

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 })

passport-auth0

Auth0 platform authentication strategy for Passport.js

MIT
Latest version published 6 months ago

Package Health Score

75 / 100
Full package analysis

Popular passport-auth0 functions