SlideShare a Scribd company logo
Authentication in Node.js
@Jason_Pearson
with code at github.com/kaeawc
About Me
• Likes to run
• Background in Scala & Node.js
• Currently playing around with Spray and
Android
I’m not a crypto expert
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
Authentication is not just a GUI
Don’t trust the client
Authentication Scheme
• Given some request parameters over http
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/thedefinitive-guide-to-form-based-websiteauthentication#477579)
Authentication Scheme
• Given some request parameters over http
• Storing user information in some database
with validated cryptographic algorithms
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.
How your app views requests
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.
PBKDF2
• Password-Based Key Derivation Function 2
• Recommended number of iterations is 10-20k

http://en.wikipedia.org/wiki/PBKDF2
Lets Look at Some Code!
We Created a User!
About ECB vs CBC

https://pthree.org/2012/02/17/ecb-vs-cbc-encryption/
ECB = Block Cipher
• Block ciphers operate on individual blocks in
the same way
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.
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/authenticatedencryption-using-aes-gcm.html
Node & AES GCM
• https://github.com/joyent/node/pull/6317
• Support is currently being added for GCM
• Put a +1 on that issue.
So… CBC for Cookies!
We have Authentication!
References
• github.com/kaeawc/node-http-auth-example
• github.com/kaeawc/node-express-auth-example
• http://stackoverflow.com/questions/549/the-definitiveguide-to-form-based-website-authentication#477579
• http://en.wikipedia.org/wiki/PBKDF2
• https://pthree.org/2012/02/17/ecb-vs-cbc-encryption/
• http://x86overflow.blogspot.com/2013/01/authenticated
-encryption-using-aes-gcm.html
• https://github.com/joyent/node/pull/6317
• http://security.stackexchange.com/questions/3959/reco
mmended-of-iterations-when-using-pkbdf2-sha256

More Related Content

PDF
JSConf Asia: Node.js Authentication and Data Security
PDF
Node.js Authentication and Data Security
PDF
Node.js Authentication & Data Security
PDF
DWS Mobile Payments Workshop
PPS
Authentication with zend framework
PDF
What the Heck is OAuth and OpenID Connect? Connect.Tech 2017
ODP
Implementing security routines with zf2
PDF
What the Heck is OAuth and OpenID Connect - RWX 2017
JSConf Asia: Node.js Authentication and Data Security
Node.js Authentication and Data Security
Node.js Authentication & Data Security
DWS Mobile Payments Workshop
Authentication with zend framework
What the Heck is OAuth and OpenID Connect? Connect.Tech 2017
Implementing security routines with zf2
What the Heck is OAuth and OpenID Connect - RWX 2017

What's hot (20)

PPTX
Presentation on Top 10 Vulnerabilities in Web Application
PDF
Skyrocketing Web APIs
PPT
GWT
PDF
How to Develop a Rich, Native-quality User Experience for Mobile Using Web St...
PDF
Usability in the GeoWeb
PDF
W3C Content Security Policy
KEY
Plone Interactivity
PDF
Selenium for-ops
PDF
AEM responsive
PDF
Oleh Zasadnyy "Progressive Web Apps: line between web and native apps become ...
PDF
#NoXML: Eliminating XML in Spring Projects - SpringOne 2GX 2015
PDF
EnterJS 2015 - Continuous Integration for Frontend Code
PDF
Ajax Security
PDF
Building an HTML5 Video Player
PDF
Javascript talk1
PDF
State of the resource timing api
PDF
Responsive design: techniques and tricks to prepare your websites for the mul...
PDF
Djangoアプリのデプロイに関するプラクティス / Deploy django application
PDF
Vaadin with Java EE 7
PPTX
High Performance JavaScript (CapitolJS 2011)
Presentation on Top 10 Vulnerabilities in Web Application
Skyrocketing Web APIs
GWT
How to Develop a Rich, Native-quality User Experience for Mobile Using Web St...
Usability in the GeoWeb
W3C Content Security Policy
Plone Interactivity
Selenium for-ops
AEM responsive
Oleh Zasadnyy "Progressive Web Apps: line between web and native apps become ...
#NoXML: Eliminating XML in Spring Projects - SpringOne 2GX 2015
EnterJS 2015 - Continuous Integration for Frontend Code
Ajax Security
Building an HTML5 Video Player
Javascript talk1
State of the resource timing api
Responsive design: techniques and tricks to prepare your websites for the mul...
Djangoアプリのデプロイに関するプラクティス / Deploy django application
Vaadin with Java EE 7
High Performance JavaScript (CapitolJS 2011)
Ad

Viewers also liked (8)

PPT
Presentatie GVNL tijdens Leisure & Sport Totaal, 2009.
KEY
At Begin, URL Handling and REST
PPSX
The scaling story of Postman
PDF
Why vREST?
PPTX
Introduction to Node.js
PDF
RESTful API Design, Second Edition
PPTX
Secure Your REST API (The Right Way)
PPTX
40+ tips to use Postman more efficiently
Presentatie GVNL tijdens Leisure & Sport Totaal, 2009.
At Begin, URL Handling and REST
The scaling story of Postman
Why vREST?
Introduction to Node.js
RESTful API Design, Second Edition
Secure Your REST API (The Right Way)
40+ tips to use Postman more efficiently
Ad

Similar to Authentication in Node.js (20)

PPTX
Securing Your MongoDB Deployment
PPTX
SPS Ozarks 2012: Kerberos Survival Guide
PDF
Kerberos Survival Guide - St. Louis Day of .Net
PPTX
Kerberos Survival Guide: SharePointalooza
PPTX
Kerberos Survival Guide: Columbus 2015
PDF
Karmendra - Hashing, CAPTCHA's and Caching - ClubHack2008
PPTX
Kerberos Survival Guide: SharePoint Saturday Nashville 2015
ODP
21 05-2018
PDF
CNIT 129S: Ch 5: Bypassing Client-Side Controls
PDF
Securing Kubernetes Workloads
PDF
How do JavaScript frameworks impact the security of applications?
PDF
DockerCon Live 2020 - Securing Your Containerized Application with NGINX
PPTX
Ntu workshop : REST, PayPal APIs & Async
PDF
DEF CON 24 - workshop - Craig Young - brainwashing embedded systems
PDF
Kerberos survival guide
PDF
Building & Testing Scalable Rails Applications
PDF
Node.js to the rescue
PPTX
Open Policy Agent for governance as a code
PDF
PDF
CNIT 129S: Ch 3: Web Application Technologies
Securing Your MongoDB Deployment
SPS Ozarks 2012: Kerberos Survival Guide
Kerberos Survival Guide - St. Louis Day of .Net
Kerberos Survival Guide: SharePointalooza
Kerberos Survival Guide: Columbus 2015
Karmendra - Hashing, CAPTCHA's and Caching - ClubHack2008
Kerberos Survival Guide: SharePoint Saturday Nashville 2015
21 05-2018
CNIT 129S: Ch 5: Bypassing Client-Side Controls
Securing Kubernetes Workloads
How do JavaScript frameworks impact the security of applications?
DockerCon Live 2020 - Securing Your Containerized Application with NGINX
Ntu workshop : REST, PayPal APIs & Async
DEF CON 24 - workshop - Craig Young - brainwashing embedded systems
Kerberos survival guide
Building & Testing Scalable Rails Applications
Node.js to the rescue
Open Policy Agent for governance as a code
CNIT 129S: Ch 3: Web Application Technologies

Recently uploaded (20)

PPTX
sap open course for s4hana steps from ECC to s4
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
Cloud computing and distributed systems.
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Spectroscopy.pptx food analysis technology
PDF
cuic standard and advanced reporting.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Empathic Computing: Creating Shared Understanding
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
sap open course for s4hana steps from ECC to s4
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Cloud computing and distributed systems.
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Spectroscopy.pptx food analysis technology
cuic standard and advanced reporting.pdf
Review of recent advances in non-invasive hemoglobin estimation
NewMind AI Weekly Chronicles - August'25 Week I
Programs and apps: productivity, graphics, security and other tools
Mobile App Security Testing_ A Comprehensive Guide.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Reach Out and Touch Someone: Haptics and Empathic Computing
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Empathic Computing: Creating Shared Understanding
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Diabetes mellitus diagnosis method based random forest with bat algorithm

Authentication in Node.js

  • 2. About Me • Likes to run • Background in Scala & Node.js • Currently playing around with Spray and Android
  • 3. I’m not a crypto expert
  • 4. 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
  • 7. Authentication Scheme • Given some request parameters over http
  • 8. 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/thedefinitive-guide-to-form-based-websiteauthentication#477579)
  • 9. Authentication Scheme • Given some request parameters over http • Storing user information in some database with validated cryptographic algorithms
  • 10. 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.
  • 11. How your app views requests
  • 12. 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.
  • 13. PBKDF2 • Password-Based Key Derivation Function 2 • Recommended number of iterations is 10-20k http://en.wikipedia.org/wiki/PBKDF2
  • 14. Lets Look at Some Code!
  • 15. We Created a User!
  • 16. About ECB vs CBC https://pthree.org/2012/02/17/ecb-vs-cbc-encryption/
  • 17. ECB = Block Cipher • Block ciphers operate on individual blocks in the same way
  • 18. 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.
  • 19. 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/authenticatedencryption-using-aes-gcm.html
  • 20. Node & AES GCM • https://github.com/joyent/node/pull/6317 • Support is currently being added for GCM • Put a +1 on that issue.
  • 21. So… CBC for Cookies!
  • 23. References • github.com/kaeawc/node-http-auth-example • github.com/kaeawc/node-express-auth-example • http://stackoverflow.com/questions/549/the-definitiveguide-to-form-based-website-authentication#477579 • http://en.wikipedia.org/wiki/PBKDF2 • https://pthree.org/2012/02/17/ecb-vs-cbc-encryption/ • http://x86overflow.blogspot.com/2013/01/authenticated -encryption-using-aes-gcm.html • https://github.com/joyent/node/pull/6317 • http://security.stackexchange.com/questions/3959/reco mmended-of-iterations-when-using-pkbdf2-sha256