SlideShare a Scribd company logo
Restful Authentication 
System with AngularJS & 
NodeJS
Hüseyin BABAL 
Full Stack Developer 
PHP, JAVA, NodeJS developer. 
Building highly scalable, realtime systems. 
Web Development mentor. 
Entrepreneur. 
NodeJS trainer. 
GDG conference speaker 
@huseyinb 
abal 
@huseyinba 
bal 
http://huseyinbab 
al.net
POST /signin 
username=.....&password=...... 
HTTP 200 
Set-Cookie: session=....... 
POST /user/me 
Cookie: session=....... 
HTTP 200 
{name: john, surname: doe, …..} 
http://app.yoursite.com http://app.yoursite.com
Boss: I want native mobile and desktop version 
of our current web application 
Developer: We need to develop new services 
for specific clients. 
Boss: What about cost? You need to find 
another solution better 
Developer: ???
My App I need to develop client 
Andr 
oid 
Window 
s 8 
iOS 
Desktop 
App 
independent system...
POST /signin 
username=.....&password=...... 
HTTP 200 
token: JWT (Bearer Token) 
POST /user/me 
Authorization: Bearer JWT(Bearer 
THoTkTePn )200 
{name: john, surname: doe, …..} 
http://app.yoursite.com http://api.yoursite.com
Wait! What is 
Bearer Token?
JWT 
Powerful token format used in HTTP headers in 
order to make some endpoint secure. 
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJz 
dWIiOjEyMzQ1Njc4OTAsIm5hbWUiOiJKb2huI 
ERvZSIsImFkbWluIjp0cnVlfQ.eoaDVGTClRdfx 
UZXiPs3f8FmJDkDE_VCQFXqKxpLsts
JWT 
header payload signatur 
e 
b64({ 
typ: ‘JWT’, 
alg: ‘HS256’ 
}) 
HMACSHA256(b64( 
header) + “.” + 
b64(payload), 
secret_key) 
b64({ 
name: 
“John”, 
id: 
“123456”, 
role: 
“admin” 
}) 
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjEyMzQ1Njc4OTAsIm5h 
bWUiOiJKb2huIERvZSIsImFkbWluIjp0cnVlfQ.eoaDVGTClRdfxUZXiPs3f8Fm 
JDkDE_VCQFXqKxpLsts
Libraries 
Language Library Url 
PHP https://github.com/firebase/php-jwt 
.NET https://github.com/AzureAD/azure-activedirectory- 
identitymodel-extensions-for- 
dotnet 
Ruby https://github.com/progrium/ruby-jwt 
NodeJS https://github.com/auth0/node-jsonwebtoken 
Java https://github.com/auth0/java-jwt 
Python https://github.com/progrium/pyjwt/
Architectur 
e 
Time
Mongo 
DB 
http://api.yoursite. 
com 
POST /signin 
username=.....&password=...... 
HTTP 200 
token: JWT (Bearer Token) 
POST /user/me 
Authorization: Bearer JWT(Bearer 
THoTkTePn )200 
{name: john, surname: doe, …..} 
http://app.yoursite.com 
Check Username and Password, create 
token if valid, add to DB 
Check token from db whenever a 
request come 
http://t1.yoursite. 
com 
…….. 
http://tn.yoursite.c 
om 
(Load 
balancer)
Advantages 
Client independent 
CDN 
Zero Coupling 
No cookie(session), no csrf 
Persistent token store 
Available for other languages (JWT token)
Demo
Thank you! 
Thank you

More Related Content

What's hot (20)

PPTX
Micro Web Service - Slim and JWT
Tuyen Vuong
 
PPTX
Securing RESTful APIs using OAuth 2 and OpenID Connect
Jonathan LeBlanc
 
PDF
What are JSON Web Tokens and Why Should I Care?
Derek Edwards
 
PPTX
An Introduction to OAuth2
Aaron Parecki
 
PDF
JSON Web Tokens
Ivan Rosolen
 
PPTX
Securing Single Page Applications with Token Based Authentication
Stefan Achtsnit
 
PDF
Authentication: Cookies vs JWTs and why you’re doing it wrong
Derek Perkins
 
PPTX
REST Service Authetication with TLS & JWTs
Jon Todd
 
PDF
OAuth Hacks A gentle introduction to OAuth 2 and Apache Oltu
Antonio Sanso
 
PDF
Stateless authentication with OAuth 2 and JWT - JavaZone 2015
Alvaro Sanchez-Mariscal
 
PDF
OAuth 2.0
Uwe Friedrichsen
 
PPTX
Single-Page-Application & REST security
Igor Bossenko
 
PDF
Using JSON Web Tokens for REST Authentication
Mediacurrent
 
PDF
Modern Security with OAuth 2.0 and JWT and Spring by Dmitry Buzdin
Java User Group Latvia
 
PDF
Rest Security with JAX-RS
Frank Kim
 
PDF
iMasters Intercon 2016 - Identity within Microservices
Erick Belluci Tedeschi
 
PDF
Introduction to JWT and How to integrate with Spring Security
Bruno Henrique Rother
 
PDF
Stateless authentication for microservices - Greach 2015
Alvaro Sanchez-Mariscal
 
PDF
Stateless Auth using OAuth2 & JWT
Gaurav Roy
 
PDF
Building an API Security Ecosystem
Prabath Siriwardena
 
Micro Web Service - Slim and JWT
Tuyen Vuong
 
Securing RESTful APIs using OAuth 2 and OpenID Connect
Jonathan LeBlanc
 
What are JSON Web Tokens and Why Should I Care?
Derek Edwards
 
An Introduction to OAuth2
Aaron Parecki
 
JSON Web Tokens
Ivan Rosolen
 
Securing Single Page Applications with Token Based Authentication
Stefan Achtsnit
 
Authentication: Cookies vs JWTs and why you’re doing it wrong
Derek Perkins
 
REST Service Authetication with TLS & JWTs
Jon Todd
 
OAuth Hacks A gentle introduction to OAuth 2 and Apache Oltu
Antonio Sanso
 
Stateless authentication with OAuth 2 and JWT - JavaZone 2015
Alvaro Sanchez-Mariscal
 
OAuth 2.0
Uwe Friedrichsen
 
Single-Page-Application & REST security
Igor Bossenko
 
Using JSON Web Tokens for REST Authentication
Mediacurrent
 
Modern Security with OAuth 2.0 and JWT and Spring by Dmitry Buzdin
Java User Group Latvia
 
Rest Security with JAX-RS
Frank Kim
 
iMasters Intercon 2016 - Identity within Microservices
Erick Belluci Tedeschi
 
Introduction to JWT and How to integrate with Spring Security
Bruno Henrique Rother
 
Stateless authentication for microservices - Greach 2015
Alvaro Sanchez-Mariscal
 
Stateless Auth using OAuth2 & JWT
Gaurav Roy
 
Building an API Security Ecosystem
Prabath Siriwardena
 

Similar to Token Based Authentication Systems with AngularJS & NodeJS (20)

PPT
Sanjeev ghai 12
Praveen kumar
 
PPTX
Demystifying REST
Kirsten Hunter
 
PDF
InterCon 2016 - Segurança de identidade digital levando em consideração uma a...
iMasters
 
KEY
Html5 For Jjugccc2009fall
Shumpei Shiraishi
 
PPTX
Python Code Camp for Professionals 3/4
DEVCON
 
PDF
5.node js
Geunhyung Kim
 
PPTX
"Your script just killed my site" by Steve Souders
Dmitry Makarchuk
 
PDF
HTML for the Mobile Web, Firefox OS
All Things Open
 
PPTX
Welcome Firefox OS in india with your app - Mumbai Firefox OS hackathon - 201...
Frédéric Harper
 
PDF
Connect Intergration Patterns: A Case Study - Patrick Streule
Atlassian
 
KEY
OSCON 2011 Learning CouchDB
Bradley Holt
 
PPTX
Web scraping 101 with goutte
Joshua Copeland
 
PDF
HTML5: friend or foe (to Flash)?
Remy Sharp
 
PPTX
REST with Eve and Python
PiXeL16
 
PDF
Securing Your Containerized Applications with NGINX
Docker, Inc.
 
PDF
Node.js introduction
Parth Joshi
 
PDF
Nko workshop - node js crud & deploy
Simon Su
 
PPTX
Token based-oauth2
andreyradzkov
 
PDF
Webové aplikace v JavaScriptu
Pavol Hejný
 
PDF
L1. Introduction, CSE 202, BN11.pdf JavaScript
SauravBarua11
 
Sanjeev ghai 12
Praveen kumar
 
Demystifying REST
Kirsten Hunter
 
InterCon 2016 - Segurança de identidade digital levando em consideração uma a...
iMasters
 
Html5 For Jjugccc2009fall
Shumpei Shiraishi
 
Python Code Camp for Professionals 3/4
DEVCON
 
5.node js
Geunhyung Kim
 
"Your script just killed my site" by Steve Souders
Dmitry Makarchuk
 
HTML for the Mobile Web, Firefox OS
All Things Open
 
Welcome Firefox OS in india with your app - Mumbai Firefox OS hackathon - 201...
Frédéric Harper
 
Connect Intergration Patterns: A Case Study - Patrick Streule
Atlassian
 
OSCON 2011 Learning CouchDB
Bradley Holt
 
Web scraping 101 with goutte
Joshua Copeland
 
HTML5: friend or foe (to Flash)?
Remy Sharp
 
REST with Eve and Python
PiXeL16
 
Securing Your Containerized Applications with NGINX
Docker, Inc.
 
Node.js introduction
Parth Joshi
 
Nko workshop - node js crud & deploy
Simon Su
 
Token based-oauth2
andreyradzkov
 
Webové aplikace v JavaScriptu
Pavol Hejný
 
L1. Introduction, CSE 202, BN11.pdf JavaScript
SauravBarua11
 
Ad

More from Hüseyin BABAL (8)

PPTX
Infinite Scalable Systems with Docker
Hüseyin BABAL
 
PPTX
MongoDB GeoSpatial Feature
Hüseyin BABAL
 
PPTX
NodeJS ve API Tasarım Temelleri
Hüseyin BABAL
 
PPTX
RESTful API Design Fundamentals
Hüseyin BABAL
 
PPTX
Token Based Authentication Systems
Hüseyin BABAL
 
PDF
Make Your Application Social
Hüseyin BABAL
 
PDF
Realtime web applications with ExpressJS and SocketIO
Hüseyin BABAL
 
PDF
Complete MVC on NodeJS
Hüseyin BABAL
 
Infinite Scalable Systems with Docker
Hüseyin BABAL
 
MongoDB GeoSpatial Feature
Hüseyin BABAL
 
NodeJS ve API Tasarım Temelleri
Hüseyin BABAL
 
RESTful API Design Fundamentals
Hüseyin BABAL
 
Token Based Authentication Systems
Hüseyin BABAL
 
Make Your Application Social
Hüseyin BABAL
 
Realtime web applications with ExpressJS and SocketIO
Hüseyin BABAL
 
Complete MVC on NodeJS
Hüseyin BABAL
 
Ad

Recently uploaded (20)

PDF
Online Queue Management System for Public Service Offices in Nepal [Focused i...
Rishab Acharya
 
PDF
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
PPTX
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PPTX
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
PPTX
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
PDF
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
PPTX
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
PPTX
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
PDF
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
PPTX
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
PDF
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
PDF
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
PPTX
Human Resources Information System (HRIS)
Amity University, Patna
 
PPTX
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PDF
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
Online Queue Management System for Public Service Offices in Nepal [Focused i...
Rishab Acharya
 
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
Human Resources Information System (HRIS)
Amity University, Patna
 
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 

Token Based Authentication Systems with AngularJS & NodeJS

  • 1. Restful Authentication System with AngularJS & NodeJS
  • 2. Hüseyin BABAL Full Stack Developer PHP, JAVA, NodeJS developer. Building highly scalable, realtime systems. Web Development mentor. Entrepreneur. NodeJS trainer. GDG conference speaker @huseyinb abal @huseyinba bal http://huseyinbab al.net
  • 3. POST /signin username=.....&password=...... HTTP 200 Set-Cookie: session=....... POST /user/me Cookie: session=....... HTTP 200 {name: john, surname: doe, …..} http://app.yoursite.com http://app.yoursite.com
  • 4. Boss: I want native mobile and desktop version of our current web application Developer: We need to develop new services for specific clients. Boss: What about cost? You need to find another solution better Developer: ???
  • 5. My App I need to develop client Andr oid Window s 8 iOS Desktop App independent system...
  • 6. POST /signin username=.....&password=...... HTTP 200 token: JWT (Bearer Token) POST /user/me Authorization: Bearer JWT(Bearer THoTkTePn )200 {name: john, surname: doe, …..} http://app.yoursite.com http://api.yoursite.com
  • 7. Wait! What is Bearer Token?
  • 8. JWT Powerful token format used in HTTP headers in order to make some endpoint secure. eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJz dWIiOjEyMzQ1Njc4OTAsIm5hbWUiOiJKb2huI ERvZSIsImFkbWluIjp0cnVlfQ.eoaDVGTClRdfx UZXiPs3f8FmJDkDE_VCQFXqKxpLsts
  • 9. JWT header payload signatur e b64({ typ: ‘JWT’, alg: ‘HS256’ }) HMACSHA256(b64( header) + “.” + b64(payload), secret_key) b64({ name: “John”, id: “123456”, role: “admin” }) eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjEyMzQ1Njc4OTAsIm5h bWUiOiJKb2huIERvZSIsImFkbWluIjp0cnVlfQ.eoaDVGTClRdfxUZXiPs3f8Fm JDkDE_VCQFXqKxpLsts
  • 10. Libraries Language Library Url PHP https://github.com/firebase/php-jwt .NET https://github.com/AzureAD/azure-activedirectory- identitymodel-extensions-for- dotnet Ruby https://github.com/progrium/ruby-jwt NodeJS https://github.com/auth0/node-jsonwebtoken Java https://github.com/auth0/java-jwt Python https://github.com/progrium/pyjwt/
  • 12. Mongo DB http://api.yoursite. com POST /signin username=.....&password=...... HTTP 200 token: JWT (Bearer Token) POST /user/me Authorization: Bearer JWT(Bearer THoTkTePn )200 {name: john, surname: doe, …..} http://app.yoursite.com Check Username and Password, create token if valid, add to DB Check token from db whenever a request come http://t1.yoursite. com …….. http://tn.yoursite.c om (Load balancer)
  • 13. Advantages Client independent CDN Zero Coupling No cookie(session), no csrf Persistent token store Available for other languages (JWT token)
  • 14. Demo