Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Hooks for service `users1`. (Can be re-generated.)
const commonHooks = require('feathers-hooks-common');
const { authenticate } = require('@feathersjs/authentication').hooks;
// eslint-disable-next-line no-unused-vars
const { hashPassword, protect } = require('@feathersjs/authentication-local').hooks;
// !code: imports // !end
// ! code: used
// eslint-disable-next-line no-unused-vars
const { iff } = commonHooks;
// eslint-disable-next-line no-unused-vars
const { create, update, patch, validateCreate, validateUpdate, validatePatch } = require('./users-1.validate');
// !end
// !code: init // !end
let moduleExports = {
before: {
// Your hooks should include:
// Hooks for service `nedb2`. (Can be re-generated.)
const commonHooks = require('feathers-hooks-common');
const { authenticate } = require('@feathersjs/authentication').hooks;
// eslint-disable-next-line no-unused-vars
const nedb2Populate = require('./nedb-2.populate');
// !code: imports // !end
// ! code: used
// eslint-disable-next-line no-unused-vars
const { iff } = commonHooks;
// eslint-disable-next-line no-unused-vars
const { create, update, patch, validateCreate, validateUpdate, validatePatch } = require('./nedb-2.validate');
// !end
// !code: init // !end
let moduleExports = {
before: {
// Your hooks should include:
before: {
// Your hooks should include:
// find : authenticate('jwt')
// get : authenticate('jwt')
// create: hashPassword()
// update: hashPassword(), authenticate('jwt')
// patch : hashPassword(), authenticate('jwt')
// remove: authenticate('jwt')
// ! code: before
all: [],
find: [ authenticate('jwt') ],
get: [ authenticate('jwt') ],
create: [ hashPassword() ],
update: [ hashPassword(), authenticate('jwt') ],
patch: [ hashPassword(), authenticate('jwt') ],
remove: [ authenticate('jwt') ]
// !end
},
after: {
// Your hooks should include:
// all : protect('password') /* Must always be the last hook */
// ! code: after
all: [ protect('password') /* Must always be the last hook */ ],
find: [],
get: [],
create: [],
update: [],
patch: [],
remove: []
// !end
},
// ! code: used
// eslint-disable-next-line no-unused-vars
const { iff } = commonHooks;
// eslint-disable-next-line no-unused-vars
const { create, update, patch, validateCreate, validateUpdate, validatePatch } = require('./nedb1.validate');
// !end
// !code: init // !end
let moduleExports = {
before: {
// Your hooks should include:
// all : authenticate('jwt')
// ! code: before
all: [ authenticate('jwt') ],
find: [],
get: [],
create: [],
update: [],
patch: [],
remove: []
// !end
},
after: {
// ! code: after
all: [],
find: [],
get: [],
create: [],
update: [],
// eslint-disable-next-line no-unused-vars
const foreignKeys = [
'id',
'_id',
'nedb2Id'
];
// !end
// !code: init // !end
let moduleExports = {
before: {
// Your hooks should include:
// all : authenticate('jwt')
// find : mongoKeys(ObjectID, foreignKeys)
// ! code: before
all: [ authenticate('jwt') ],
find: [ mongoKeys(ObjectID, foreignKeys) ],
get: [],
create: [],
update: [],
patch: [],
remove: []
// !end
},
after: {
// ! code: after
all: [],
find: [],
get: [],
create: [],
update: [],
// ! code: used
// eslint-disable-next-line no-unused-vars
const { iff } = commonHooks;
// eslint-disable-next-line no-unused-vars
const { create, update, patch, validateCreate, validateUpdate, validatePatch } = require('./nedb-2.validate');
// !end
// !code: init // !end
let moduleExports = {
before: {
// Your hooks should include:
// all : authenticate('jwt')
// ! code: before
all: [ authenticate('jwt') ],
find: [],
get: [],
create: [],
update: [],
patch: [],
remove: []
// !end
},
after: {
// ! code: after
all: [],
find: [],
get: [],
create: [],
update: [],
// !end
// !code: init // !end
let moduleExports = {
before: {
// Your hooks should include:
// find : authenticate('jwt')
// get : authenticate('jwt')
// create: hashPassword()
// update: hashPassword(), authenticate('jwt')
// patch : hashPassword(), authenticate('jwt')
// remove: authenticate('jwt')
// ! code: before
all: [],
find: [ authenticate('jwt') ],
get: [ authenticate('jwt') ],
create: [ hashPassword() ],
update: [ hashPassword(), authenticate('jwt') ],
patch: [ hashPassword(), authenticate('jwt') ],
remove: [ authenticate('jwt') ]
// !end
},
after: {
// Your hooks should include:
// all : protect('password') /* Must always be the last hook */
// ! code: after
all: [ protect('password') /* Must always be the last hook */ ],
find: [],
get: [],
create: [],
let moduleExports = function (app: App) {
const config = app.get('authentication');
// !code: func_init // !end
// Set up authentication with the secret
app.configure(authentication(config));
app.configure(jwt());
app.configure(local());
// !code: loc_1 // !end
app.configure(oauth2(Object.assign({
name: 'auth0',
Strategy: Auth0Strategy,
// !code: auth0_options // !end
}, config.auth0)));
app.configure(oauth2(Object.assign({
name: 'google',
Strategy: GoogleStrategy,
// !code: google_options // !end
}, config.google)));
const Verifier = options.Verifier || DefaultVerifier;
const formatter = options.formatter || rest.formatter;
const handler = options.handler || defaultHandler(oauth2Settings);
const errorHandler = typeof options.errorHandler === 'function' ? options.errorHandler(oauth2Settings) : defaultErrorHandler(oauth2Settings);
// register OAuth middleware
debug(`Registering '${name}' Express OAuth middleware`);
app.get(oauth2Settings.path, auth.express.authenticate(name, omit(oauth2Settings, 'state')));
app.get(
oauth2Settings.callbackPath,
_callbackAuthenticator(authSettings),
auth.express.authenticate(name, omit(oauth2Settings, 'state')),
handler,
errorHandler,
auth.express.emitEvents(authSettings, app),
auth.express.setCookie(authSettings),
auth.express.successRedirect(),
auth.express.failureRedirect(authSettings),
formatter
);
app.setup = function () {
let result = _super.apply(this, arguments);
let verifier = new Verifier(app, oauth2Settings);
if (!verifier.verify) {
throw new Error(`Your verifier must implement a 'verify' function. It should have the same signature as a oauth2 passport verify callback.`);
}
// Register 'oauth2' strategy with passport
debug('Registering oauth2 authentication strategy with options:', oauth2Settings);
app.service('authentication').hooks({
before: {
create: [
(context) => {
/* Stringify the signature JSON to make the lookup() function in
* passport-local/utils happy
*
* Somewhat related to
* https://github.com/jaredhanson/passport-local/issues/153
*/
if (context.data.signature) {
context.data.password = JSON.stringify(context.data.signature);
}
return context;
},
authentication.hooks.authenticate(['local', 'jwt'])
]
}
});
/*
* Initialize the Sentry backend integration for reporting error telemetry
*/
app.set('sentry', new Sentry(process.env.SENTRY_URL || app.get('sentry').url));
if (process.env.NODE_ENV != 'production') {
app.configure(swagger({
docsPath: '/apidocs',
uiIndex: true,
info: {
title: 'Evergreen Backend APIs',
description: