23
Authentication in Node.js @Jason_Pearson with code at github.com/kaeawc

Authentication in Node.js

Embed Size (px)

Citation preview

Page 1: Authentication in Node.js

Authentication in Node.js

@Jason_Pearsonwith code at github.com/kaeawc

Page 2: Authentication in Node.js

About Me

• Likes to run• Background in Scala & Node.js• Currently playing around with Spray and

Android

Page 3: Authentication in Node.js

I’m not a crypto expert

Page 4: Authentication in Node.js

Covered In This Talk

• low level http app– github.com/kaeawc/node-http-auth-example

• express + passport app– github.com/kaeawc/node-express-auth-example

Page 5: Authentication in Node.js

Authentication is not just a GUI

Page 6: Authentication in Node.js

Don’t trust the client

Page 7: Authentication in Node.js

Authentication Scheme

• Given some request parameters over http

Page 8: Authentication in Node.js

Storing Credentials

• Some data store is required.

• Any credential should never be stored as plaintext in the database.

• They should be hashed with a unique salt.

• Read more: (http://stackoverflow.com/questions/549/the-definitive-guide-to-form-based-website-authentication#477579)

Page 9: Authentication in Node.js

Authentication Scheme

• Given some request parameters over http

• Storing user information in some database with validated cryptographic algorithms

Page 10: Authentication in Node.js

Load Balanced = Stateless

• You cannot maintain state in an application server’s memory– App server memory needs to be reserved for

processing requests.– This eventually results in moving state to a load

balanced cache anyway.

Page 11: Authentication in Node.js

How your app views requests

Page 12: Authentication in Node.js

Authentication Scheme

• Given some request parameters over http

• Storing user information in some database

• Application is load balanced over N servers, so every request must check.

Page 13: Authentication in Node.js

PBKDF2

• Password-Based Key Derivation Function 2

• Recommended number of iterations is 10-20k

http://en.wikipedia.org/wiki/PBKDF2

Page 14: Authentication in Node.js

Lets Look at Some Code!

Page 15: Authentication in Node.js

We Created a User!

Page 16: Authentication in Node.js

About ECB vs CBC

https://pthree.org/2012/02/17/ecb-vs-cbc-encryption/

Page 17: Authentication in Node.js

ECB = Block Cipher

• Block ciphers operate on individual blocks in the same way

Page 18: Authentication in Node.js

CBC = Streaming Cipher

• Takes an initialization vector, or “iv”, which is used with the password on the first block to encrypt and then produce the next vector for the next block.

Page 19: Authentication in Node.js

GCM = Galois/Counter Mode

• Example of Authenticated Encryption– Provides both data integrity and confidentiality– Depends on using a different vector with the same

key– Can only be decrypted with the same key and

vector

Read more: http://x86overflow.blogspot.com/2013/01/authenticated-encryption-using-aes-gcm.html

Page 20: Authentication in Node.js

Node & AES GCM

• https://github.com/joyent/node/pull/6317

• Support is currently being added for GCM

• Put a +1 on that issue.

Page 21: Authentication in Node.js

So… CBC for Cookies!

Page 22: Authentication in Node.js

We have Authentication!