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
Autenticación: Vue.js + JWT
Search
Ignacio Anaya
November 02, 2017
Programming
0
1.1k
Autenticación: Vue.js + JWT
Esta charla muestra como podemos implementar autenticacion JWT en SPA's desarrolladas con Vue.js
Ignacio Anaya
November 02, 2017
Tweet
Share
More Decks by Ignacio Anaya
See All by Ignacio Anaya
Security is not a feature‼️
ianaya89
2
500
Rompiendo Paradigmas Otra Vuez! 🔨📜3️⃣
ianaya89
0
140
Security is not a feature!
ianaya89
1
360
What's next in Vue 3? 🖖 3️⃣
ianaya89
0
130
What's next in Vue 3? 🖖 3️⃣
ianaya89
0
290
Vue.js, PWA & The Subway Dilemma
ianaya89
0
200
PWA with PWF
ianaya89
0
69
Decentralizing the Web with JavaScript
ianaya89
0
140
hey-devs-time-to-care-about-web-apps-security.pdf
ianaya89
0
120
Other Decks in Programming
See All in Programming
EMこそClaude Codeでコード調査しよう
shibayu36
0
240
はじめてのDSPy - 言語モデルを『プロンプト』ではなく『プログラミング』するための仕組み
masahiro_nishimi
3
720
あなたとKaigi on Rails / Kaigi on Rails + You
shimoju
0
170
Developer Joy - The New Paradigm
hollycummins
1
250
iOSエンジニア向けの英語学習アプリを作る!
yukawashouhei
0
200
SwiftDataを使って10万件のデータを読み書きする
akidon0000
0
230
他言語経験者が Golangci-lint を最初のコーディングメンターにした話 / How Golangci-lint Became My First Coding Mentor: A Story from a Polyglot Programmer
uma31
0
310
タスクの特性や不確実性に応じた最適な作業スタイルの選択(ペアプロ・モブプロ・ソロプロ)と実践 / Optimal Work Style Selection: Pair, Mob, or Solo Programming.
honyanya
3
180
When Dependencies Fail: Building Antifragile Applications in a Fragile World
selcukusta
0
110
Android16 Migration Stories ~Building a Pattern for Android OS upgrades~
reoandroider
0
130
Six and a half ridiculous things to do with Quarkus
hollycummins
0
190
Webサーバーサイド言語としてのRustについて
kouyuume
0
570
Featured
See All Featured
The World Runs on Bad Software
bkeepers
PRO
72
11k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.5k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3.1k
We Have a Design System, Now What?
morganepeng
53
7.8k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
253
22k
For a Future-Friendly Web
brad_frost
180
10k
Learning to Love Humans: Emotional Interface Design
aarron
274
41k
Reflections from 52 weeks, 52 projects
jeffersonlam
353
21k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
10
600
The Power of CSS Pseudo Elements
geoffreycrofte
79
6k
Balancing Empowerment & Direction
lara
5
690
Designing for Performance
lara
610
69k
Transcript
Autenticación: Vue.js + JWT { Autenticación: Vue.js + JWT }
- @ianaya89 1
Ignacio Anaya @ianaya89 > Full Stack Developer, Tech Trainer &
Speaker > Embajador @Auth0 > Organizador @Vuenos_Aires { Autenticación: Vue.js + JWT } - @ianaya89 2
! Por Qué Token? — Sin Estado — Desacoplado —
Escalable { Autenticación: Vue.js + JWT } - @ianaya89 3
{ Autenticación: Vue.js + JWT } - @ianaya89 4
! Por Qué JWT? — Estandard — Seguro — Auto
Contenido — JSON ! { Autenticación: Vue.js + JWT } - @ianaya89 5
! JWT { Autenticación: Vue.js + JWT } - @ianaya89
6
! JWT ! Header { "alg": "HS256", "typ": "JWT" }
{ Autenticación: Vue.js + JWT } - @ianaya89 7
! JWT ! Payload { "sub": "1234567890", "name": "John Doe",
"admin": true, "iss": "https://api.com" } { Autenticación: Vue.js + JWT } - @ianaya89 8
! JWT ✍ Signature HMACSHA256( base64UrlEncode(header) + "." + base64UrlEncode(payload),
secret ) { Autenticación: Vue.js + JWT } - @ianaya89 9
! JWT ! Caso de Uso — SPA's — Serverless
— API's — Mobile — IoT { Autenticación: Vue.js + JWT } - @ianaya89 10
{ Autenticación: Vue.js + JWT } - @ianaya89 11
! Herramientias — Auth API — vue-router — trae (http
library) — localStorage { Autenticación: Vue.js + JWT } - @ianaya89 12
Auth Servidor = Seguridad Auth Cliente = UX { Autenticación:
Vue.js + JWT } - @ianaya89 13
! Auth API — Obtener JWT — Validar JWT —
node, express, jsonwebtoken, express-jwt { Autenticación: Vue.js + JWT } - @ianaya89 14
! vue-router — SPA's — 1 route = 1 component
{ Autenticación: Vue.js + JWT } - @ianaya89 15
! vue-router Routes Meta const router = new Router({ routes:
[{ path: '/', component: Home }, { path: '/login', component: Login, meta: { isPublic: true } }] }) { Autenticación: Vue.js + JWT } - @ianaya89 16
! vue-router Guardian Navs router.beforeEach((to, from, next) => { //
resolver si el usuario esta logueado if (!to.meta.isPublic && !isAuthenticated()) { return next('login') } next() }) { Autenticación: Vue.js + JWT } - @ianaya89 17
! trae — Libreria HTTP — Fetch Wrapper (con esteroides)
— Similar axios — Usa Promises { Autenticación: Vue.js + JWT } - @ianaya89 18
! trae Ejemplo import trae from 'trae' trae.baseUrl('http://api:com') trae.get('/', {})
.then(res => console.log(res.data)) .catch(err => console.log('[ERROR]', err)) { Autenticación: Vue.js + JWT } - @ianaya89 19
! trae Middlewares trae.before((config) => { const token = '123456789'
config.headers['Authentication'] = token return config }) { Autenticación: Vue.js + JWT } - @ianaya89 20
! localStorage trae.post('/auth', { email, password }) .then(res => {
localStorage.token = res.data localStorage.user = atob(res.data.split('.')[1]) }) .catch(err => console.log('[ERROR]', err)) { Autenticación: Vue.js + JWT } - @ianaya89 21
! Demo — API — Web App { Autenticación: Vue.js
+ JWT } - @ianaya89 22
! Más! — jwt.io — Auth0 — jwt-handbook — trae
— vue-router { Autenticación: Vue.js + JWT } - @ianaya89 23
Preguntas? { Autenticación: Vue.js + JWT } - @ianaya89 24
! Gracias! @ianaya89 { Autenticación: Vue.js + JWT } -
@ianaya89 25