Skip to content

Commit

Permalink
Adding code to prevent attacks (#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
pranjals149 authored Aug 7, 2020
1 parent c2b4884 commit 57a0cf9
Show file tree
Hide file tree
Showing 2 changed files with 243 additions and 2 deletions.
22 changes: 22 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ const morgan = require('morgan')
const cookieParser = require('cookie-parser')
const createError = require('http-errors')
const path = require('path')

const socket = require('socket.io')
const multer = require('multer')
const bodyParser = require('body-parser')
const cors = require('cors')
var winston = require('./config/winston')
const fileConstants = require('./config/fileHandlingConstants')


const indexRouter = require('./app/routes/index')
const authRouter = require('./app/routes/auth')
const usersRouter = require('./app/routes/user')
Expand Down Expand Up @@ -47,6 +49,26 @@ io.on('connection', (socket) => {
io.emit('user connected')
})

app.use(helmet());
app.use(hpp());

const csrfMiddleware = csurf({
cookie: true
});

app.use(session({
secret: 'codeuino',
resave: false,
saveUninitialized: true,
cookie: {
secure: true,
httpOnly: true
}
}));

app.use(cookieParser());
app.use(csrfMiddleware);

// view engine setup
app.set('views', path.join(__dirname, 'views'))
app.set('view engine', 'ejs')
Expand Down
223 changes: 221 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 57a0cf9

Please sign in to comment.