Files
freeCodeCamp/api-server/src/server/passport-providers.js
2023-08-29 18:35:27 +05:30

49 lines
1.4 KiB
JavaScript

import { auth0 } from '../../config/secrets';
const { clientID, clientSecret, domain } = auth0;
// These don't seem to be used, can they go?
const successRedirect = `${process.env.HOME_LOCATION}/learn`;
const failureRedirect = `${process.env.HOME_LOCATION}/signin`;
// TODO: can we remove passport-mock-strategy entirely in prod? That would let
// us make passport-mock-strategy a dev dep, as it should be.
const passportProviders = {
devlogin: {
authScheme: 'mock',
provider: 'dev',
module: 'passport-mock-strategy'
},
local: {
provider: 'local',
module: 'passport-local',
usernameField: 'email',
passwordField: 'password',
authPath: '/auth/local',
successRedirect: successRedirect,
failureRedirect: failureRedirect,
session: true,
failureFlash: true
},
'auth0-login': {
provider: 'auth0',
module: 'passport-auth0',
clientID,
clientSecret,
domain,
cookieDomain: process.env.COOKIE_DOMAIN || 'localhost',
callbackURL: `${process.env.API_LOCATION}/auth/auth0/callback`,
authPath: '/auth/auth0',
callbackPath: '/auth/auth0/callback',
useCustomCallback: true,
passReqToCallback: true,
state: false,
successRedirect: successRedirect,
failureRedirect: failureRedirect,
scope: ['openid profile email'],
failureFlash: true
}
};
export default passportProviders;