Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Properly Securing Node.js APIs
Search
Chathu Vishwajith
September 22, 2018
Programming
0
58
Properly Securing Node.js APIs
Properly securing Node.js APIs at WebWeekend Kathmandu #WWKTM .
Chathu Vishwajith
September 22, 2018
Tweet
Share
More Decks by Chathu Vishwajith
See All by Chathu Vishwajith
Lerna and Monorepo architecture for JavaScript
iamchathu
0
67
Hardening WordPress is kind of Art
iamchathu
0
130
It's Someone Else's Servers
iamchathu
0
44
Hardening WordPress is An Art
iamchathu
0
140
Speed Up Your WordPess
iamchathu
0
110
CMBJS Meetup: Securing NodeJS APIs with JWT
iamchathu
0
110
Other Decks in Programming
See All in Programming
モテるデスク環境
mozumasu
3
1.4k
AI 駆動開発におけるコミュニティと AWS CDK の価値
konokenj
5
320
マンガアプリViewerの大画面対応を考える
kk__777
0
450
自動テストのアーキテクチャとその理由ー大規模ゲーム開発の場合ー
segadevtech
0
330
Claude Agent SDK を使ってみよう
hyshu
0
1.5k
TransformerからMCPまで(現代AIを理解するための羅針盤)
mickey_kubo
7
5.9k
Node-REDのノードの開発・活用事例とコミュニティとの関わり(Node-RED Con Nagoya 2025)
404background
0
110
ALL CODE BASE ARE BELONG TO STUDY
uzulla
29
6.9k
オンデバイスAIとXcode
ryodeveloper
0
380
フロントエンド開発のためのブラウザ組み込みAI入門
masashi
7
3.7k
SwiftDataを使って10万件のデータを読み書きする
akidon0000
0
250
SODA - FACT BOOK(JP)
sodainc
1
9.2k
Featured
See All Featured
YesSQL, Process and Tooling at Scale
rocio
174
15k
Documentation Writing (for coders)
carmenintech
76
5.1k
How to Ace a Technical Interview
jacobian
280
24k
The World Runs on Bad Software
bkeepers
PRO
72
11k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
127
54k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
Scaling GitHub
holman
463
140k
RailsConf 2023
tenderlove
30
1.3k
How STYLIGHT went responsive
nonsquared
100
5.9k
Unsuck your backbone
ammeep
671
58k
Building Adaptive Systems
keathley
44
2.8k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.5k
Transcript
WebWeekend Kathmandu
Perfectly Securing Node.js APIs
Who am I Chathu Vishwajith Auth0 Ambassador Co-Founder of a
startup From Sri Lanka !
?
Cookie vs Tokens
Cookie vs Tokens
Cookie Tokens Statefull Stateless Performance Decoupled
Advantages of JWT → Stateless → Scalable → Decoupled
Advantages of JWT (Cont) → Cross-Domain → CORS
Use cases JWT (Cont) → Back-end APIs → Serverless Applications
→ IOT Devices → Mobile Applications
Things to Remember → JWTs are encoded not encrypted! →
This does not mean they can modify it though, even the slightest change will invalidate the token → Do not store sensitive information within a JWT. → Solution: JSON Web Encryption allows you to safely encrypt the claims of a token
JWT Token Structure header.payload.signature
Header Type of token and hashing algorithm → HMAC →
ECDSA → RSA
Payload Your Token Payload
Signature Verification of Token
Libraries Almost all languages has JWT implementation.
How to use JWT
Install JWT Library For Node.js and Express.js
Create JWT
Verify JWT
Organizing code → Module based approach. → Configuration in files.
→ Auto load models and routes. → Keep your secret secret.
Config file Keep all changing config strings in one place.
.env file we use dotenv to load .env file.
Shall we move to code work though?
Summery → Some APIs needs to secure → Cookie vs
Tokens → JWT is Stateless, Scalable, Decoupled → How to use JWT with Node.js
Code repository https://github.com/iamchathu/nodejs-api-starter
More Reading https://chathu.me/2017/08/28/jwt-introduction/
None
Thank you !