Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const Mongoose = require('mongoose')
const Boom = require('boom')
const RestHapi = require('rest-hapi')
const errorHelper = require('../utilities/error-helper')
const Config = require('../../config')
const Token = require('../utilities/create-token')
const AUTH_STRATEGIES = Config.get('/constants/AUTH_STRATEGIES')
const socialPassword = Config.get('/socialPassword')
const socialIds = Config.get('/socialIds')
const socialSecrets = Config.get('/socialSecrets')
const EXPIRATION_PERIOD = Config.get('/constants/EXPIRATION_PERIOD')
const isSecure = Config.get('/socialSecure')
const logger = RestHapi.getLogger('appy')
const internals = {}
module.exports = {
plugin: {
name: 'auth',
register
}
}
internals.applyTokenStrategy = function(server) {
// const Log = logger.bind('auth/standard-jwt')
server.auth.strategy(AUTH_STRATEGIES.TOKEN, 'jwt', {
key: Config.get('/jwtSecret'),
verifyOptions: { algorithms: ['HS256'] },
gulp.task('update-permissions', [], function () {
RestHapi.config.loglevel = 'DEBUG'
const Log = RestHapi.getLogger('update-permissions')
return updatePermissions()
.then(function (result) {
return gulp.src('')
.pipe(exit())
})
.catch(function (error) {
Log.error(error)
})
})
'use strict';
const Hapi = require('hapi');
const config = require('../config').get('/restHapiConfig');
const Auth = require('./utilities/auth');
const mongoose = require('mongoose');
const restHapi = require('rest-hapi');
const Log = restHapi.getLogger('appy');
function apiInit() {
const server = new Hapi.Server();
server.connection({
port: config.server.port,
routes: {
cors: {
additionalHeaders: ['X-Total-Count'],
additionalExposedHeaders: ['X-Total-Count']
}
}
});
restHapi.config = config;
return server.start((err) => {
RestHapi.config.loglevel = 'DEBUG'
const Log = RestHapi.getLogger('seed')
faker.seed(4997)
const password = 'root'
const pin = '1234'
let roles = []
let users = []
let groups = []
let visitors = []
let permissions = []
let adminPermissions = []
let permissionNames = []
let request = {}
const Mongoose = require('mongoose');
const Boom = require('boom');
const RestHapi = require('rest-hapi');
const Config = require('../config');
const Token = require('./token');
const AUTH_STRATEGIES = Config.get('/constants/AUTH_STRATEGIES');
const socialPassword = Config.get('/socialPassword');
const socialIds = Config.get('/socialIds');
const socialSecrets = Config.get('/socialSecrets');
const expirationPeriod = Config.get('/expirationPeriod');
const isSecure = Config.get('/socialSecure')
const logger = RestHapi.getLogger('appy');
const internals = {};
internals.applyTokenStrategy = function (server, next) {
const Log = logger.bind("auth/standard-jwt");
server.auth.strategy(AUTH_STRATEGIES.TOKEN, 'jwt', {
key: Config.get('/jwtSecret'),
verifyOptions: { algorithms: ['HS256'] },
validateFunc: function (decodedToken, request, callback) {
let user = decodedToken.user;
callback(null, Boolean(user), { user, scope: decodedToken.scope });
;(async function seed() {
RestHapi.config.loglevel = 'DEBUG'
const Log = RestHapi.getLogger('seed')
try {
RestHapi.config = restHapiConfig
RestHapi.config.absoluteModelPath = true
RestHapi.config.modelPath = path.join(__dirname, '/../server/models')
let models = await RestHapi.generateModels(Mongoose)
const composeOptions = {
relativeTo: path.join(__dirname, '/../')
}
const manifest = Manifest.get('/')
const server = await Glue.compose(manifest, composeOptions)
await server.start()
function updatePermissions () {
RestHapi.config.loglevel = 'DEBUG'
const Log = RestHapi.getLogger('update-permissions')
let promise = {}
if (models) {
promise = Q.when(models)
}
else {
Mongoose.Promise = Q.Promise
RestHapi.config = restHapiConfig
RestHapi.config.absoluteModelPath = true
RestHapi.config.modelPath = __dirname + '/../server/models'
Mongoose.connect(restHapiConfig.mongo.URI)
promise = RestHapi.generateModels(Mongoose)
'use strict';
const Mongoose = require('mongoose');
const Boom = require('boom');
const RestHapi = require('rest-hapi');
const Config = require('../config');
const Token = require('./token');
const AUTH_STRATEGIES = Config.get('/constants/AUTH_STRATEGIES');
const socialPassword = Config.get('/socialPassword');
const socialIds = Config.get('/socialIds');
const socialSecrets = Config.get('/socialSecrets');
const expirationPeriod = Config.get('/expirationPeriod');
const logger = RestHapi.getLogger('appy');
const internals = {};
internals.applyTokenStrategy = function (server, next) {
const Log = logger.bind("auth/standard-jwt");
server.auth.strategy(AUTH_STRATEGIES.TOKEN, 'jwt', {
key: Config.get('/jwtSecret'),
verifyOptions: { algorithms: ['HS256'] },
validateFunc: function (decodedToken, request, callback) {
let user = decodedToken.user;
callback(null, Boolean(user), { user, scope: decodedToken.scope });
function dropCollections (models) {
const mongoose = require('mongoose')
RestHapi.config.loglevel = 'LOG'
const Log = RestHapi.getLogger('unseed')
Log.log('removing users')
return models.user.remove({})
.then(function () {
Log.log('removing roles')
return models.role.remove({})
})
.then(function () {
Log.log('removing groups')
return models.group.remove({})
})
.then(function () {
Log.log('removing permissions')
return models.permission.remove({})
})
.then(function () {