Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)));
app.configure(oauth2(Object.assign({
name: 'facebook',
enabled: true,
name: COOKIE_NAME,
httpOnly: false,
secure: false
},
jwt: {
header: { typ: 'access' },
audience: ORIGIN,
subject: 'authentication',
issuer: 'frontless',
algorithm: 'HS256',
expiresIn: '10d' // the access token expiry
},
}))
app.configure(local({
session: true,
usernameField: 'username',
passwordField: 'password',
entityUsernameField: 'username',
entityPasswordField: 'password',
Verifier,
}))
const dir = __dirname + '/..'
app.emit('setup:ssr', app)
app.use('/*@:args', Frontless(dir, ['styles']))
app.use('/*', Frontless(dir, ['styles']))
app.use((err, req, res, next) => {
const {type, code} = err;
if (type === 'FeathersError') {
let moduleExports = function (app: App) {
const config = app.get('authentication');
// 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
}, config.auth0)));
app.configure(oauth2(Object.assign({
name: 'google',
Strategy: GoogleStrategy
}, config.google)));
app.configure(oauth2(Object.assign({
name: 'facebook',
Strategy: FacebookStrategy
}, config.facebook)));
// corsMiddleware(socket.request, socket.request.res, next);
// });
io.use(function(socket, next) {
sessionMiddleware(socket.request, socket.request.res, next);
});
io.use(function(socket, next) {
socket.feathers.request = socket.request;
next();
});
}));
app.configure(authentication({
session: true,
secret: process.env.REST_AUTH_SECRET,
service: process.env.REST_AUTH_SERVICE,
}));
app.configure(local());
configure(app, express);
app.use('/*', FrontLessMidleware);
services(app);
return app;
};
import feathers, { Application } from '@feathersjs/feathers';
import feathersAuthenticationLocal from '@feathersjs/authentication-local';
const app: Application = feathers().configure(feathersAuthenticationLocal());
app.use('/assets', express.static('assets'))
app.use(corsMiddleware)
app.use(sessionMiddleware)
app.use(express.json())
app.use(express.urlencoded({extended: true}))
app.configure(express.rest())
app.configure(authentication({
session: true,
secret: process.env.REST_AUTH_SECRET,
service: process.env.REST_AUTH_SERVICE,
}))
app.configure(local())
app.use(function (req, res, next) {
if ('EIO' in req.query)
return next();
if (req.headers.accept &&
req.headers.accept.includes('/json')) {
return next();
}
if (req.feathers &&
req.feathers.headers.accept.includes('/json')) {
return next();
}
renderer(req, res, next);
})
app.configure(express.rest());
app.configure(socketio({}, function(io) {
io.use(function(socket, next) {
sessionMiddleware(socket.request, socket.request.res, next);
});
io.use(function(socket, next) {
socket.feathers.request = socket.request;
next();
});
}));
app.configure(authentication({
session: true,
secret: '123sd234sdfsdf',
service: 'users',
}));
app.configure(local());
/**
* FrontLess express middleware.
* Provides methods for parsing frontless HTTP requests and valid responces
* @param {Object} req - express request
* @param {Object} res - express response
* @param {Function} next - express callback
* @async
*/
export async function FrontLessMidleware(req, res, next) {
if (req.headers.accept &&
req.headers.accept.includes('/json')) {
return next();
}
const tagName = resolvePageName(req.params [0]);