Skip to content

ralexrdz/auth-intro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Node Auth Intro

  • Login
  • Logout
  • Session

JSON Web Tokens (jwt)

  • sign

const jwt = require('jsonwebtoken')
...

jwt.sign(<objeto a guardar en el payload>, 'llave-secretísima', <opciones>, <funcion-callback> (err, token) {

})

Password Hashing (bcrypt)

  • Install

$ npm i -s passport $ npm i -s passport-local $ npm i -s express-session

  • Objective: authenticate requests
  • Work as a middleware

Strageties

  • Distinct authentication mechanisms

  • In case of success authentication request will be decorated with req.user

  • LocalStrategy

Recives two params username y password, y la función done()

  • done (err) para manejar un error de servidor
  • done (null, false, {message: 'asdasd'}) error de authentication
  • done (null, credentials) para lo que queramos guardar (expose o decorate) req.user

OAuth (fb, twitter, google)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published