Security through Nodejs Flashcards

1
Q

Level 1 Security

A

Username and Password

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Level 2

A

Encrypt the password in database.
Use package ‘mongoose-encryption’

npm i mongoose-encryption

const encrypt = require(‘mongoose-encryption’);

// Initialize schema here

// schema.plugin(encrypt, { encyptedFields: [‘field-name that needs to be encrypted in a document’] } );

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Level 3

A

Hashing password with package like md5

npm i md5

const md5 = require (‘md5);

password= md5(‘some string here’);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Level 4

A

Salting and Hashing

Aim of salting and hashing is to make brute forcing more tedious.

npm install bcrypt // to install the npm module

const bcrypt = require('bcrypt');     // require in the js
const saltRounds = 10;
bcrypt.hash(myPlaintextPassword, saltRounds, function(err, hash) {
    // Store hash in your password DB.
});
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
Level 5 ( local authentication)
Level 6 (Open Authorization from external sites)
A

Cookie Session - QoL improvements

Done by using express-session, passport.js, passport-local-mongoose, passport-local

Check respective documentation for usage but –

express-session - aids in constructing and saving a session as cookie
passport.js - provides general strategy for authentication like google, fb, github, gitlab etc (Level 6)
passport-local-mongoose - helps in saving data generated from passport local to mongoose database.
passport-local - provides local strategy for authentication. (Level 5)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly