{"id":95582,"date":"2022-07-30T05:14:04","date_gmt":"2022-07-30T03:14:04","guid":{"rendered":"https:\/\/rmarketingdigital.com\/javascript\/node-hero-node-js-autenticacion-utilizando-passport-js\/"},"modified":"2020-12-03T16:57:16","modified_gmt":"2020-12-03T19:57:16","slug":"node-hero-node-js-autenticacion-utilizando-passport-js","status":"publish","type":"post","link":"https:\/\/rmarketingdigital.com\/en\/javascript\/node-hero-node-js-autenticacion-utilizando-passport-js\/","title":{"rendered":"Node Hero - Node.js Authentication using Passport.js"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_86 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewbox=\"0 0 24 24\" version=\"1.2\" baseprofile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/rmarketingdigital.com\/en\/javascript\/node-hero-node-js-autenticacion-utilizando-passport-js\/#Tecnologias-a-utilizar\" >Technologies to use<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/rmarketingdigital.com\/en\/javascript\/node-hero-node-js-autenticacion-utilizando-passport-js\/#%C2%BFQue-es-Passportjs\" >What is Passport.js?<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/rmarketingdigital.com\/en\/javascript\/node-hero-node-js-autenticacion-utilizando-passport-js\/#%C2%BFQue-es-Redis\" >What is Redis?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/rmarketingdigital.com\/en\/javascript\/node-hero-node-js-autenticacion-utilizando-passport-js\/#La-aplicacion-de-demostracion-que-necesita-autenticacion\" >The demo application that needs authentication<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/rmarketingdigital.com\/en\/javascript\/node-hero-node-js-autenticacion-utilizando-passport-js\/#La-estructura-del-proyecto\" >The structure of the project<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/rmarketingdigital.com\/en\/javascript\/node-hero-node-js-autenticacion-utilizando-passport-js\/#El-flujo-de-autenticacion-Nodejs\" >The Node.js authentication flow<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/rmarketingdigital.com\/en\/javascript\/node-hero-node-js-autenticacion-utilizando-passport-js\/#Paso-1-Configuracion-de-Express\" >Step 1: Express Configuration<\/a><ul class='ez-toc-list-level-5' ><li class='ez-toc-heading-level-5'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/rmarketingdigital.com\/en\/javascript\/node-hero-node-js-autenticacion-utilizando-passport-js\/#%C2%BFQue-hicimos-aqui\" >What did we do here?<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/rmarketingdigital.com\/en\/javascript\/node-hero-node-js-autenticacion-utilizando-passport-js\/#Paso-2-Configuracion-de-Passportjs-para-Nodejs\" >Step 2: Setting up Passport.js for Node.js<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/rmarketingdigital.com\/en\/javascript\/node-hero-node-js-autenticacion-utilizando-passport-js\/#Paso-3-Agregar-puntos-finales-protegidos\" >Step 3: Add protected endpoints<\/a><ul class='ez-toc-list-level-5' ><li class='ez-toc-heading-level-5'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/rmarketingdigital.com\/en\/javascript\/node-hero-node-js-autenticacion-utilizando-passport-js\/#Resumen-%E2%80%93-Autenticacion-con-Passportjs\" >Summary - Authentication with Passport.js<\/a><\/li><\/ul><\/li><\/ul><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<div itemprop=\"articleBody\">\n<p>This tutorial of <strong>Passport.js<\/strong> walk you through the steps to set up an authentication strategy <strong>Node.js<\/strong> local using <strong>Redis.<\/strong> You will learn to create an authentication interface with <strong>Passport.js,<\/strong> where users will provide their usernames and passwords. Despite its complexity, authentication mechanisms can be easily implemented in <strong>Node.js.<\/strong><span id=\"more-147\"\/><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Tecnologias-a-utilizar\"><\/span>Technologies to use<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Before we jump headfirst into our Passport.js authentication tutorial, let&#039;s take a look at the technologies we&#039;re going to use in this chapter.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"%C2%BFQue-es-Passportjs\"><\/span>What is Passport.js?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li><strong>Passport.js<\/strong> is an authentication middleware <strong>Node.js<\/strong> simple and discreet for <strong>Node.js<\/strong><\/li>\n<li><strong>Passport.js<\/strong> can be placed in any web-based application <em>Express.js.<\/em><\/li>\n<li><strong>Passport<\/strong> is a <em>middleware<\/em> authentication for <em>Node.js<\/em> that we are going to use for session management.<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"%C2%BFQue-es-Redis\"><\/span>What is Redis?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><strong>Redis<\/strong> is an open source (BSD licensed) in-memory data structure store, used as a database, cache, and message broker.<\/p>\n<p>Redis is designed to support different types of abstract data structures, such as strings, hashes, lists, sets, ordered sets with range queries, bitmaps, hyperlinks, and geospatial indexes with radio queries.<\/p>\n<p>We will store the information of the session of our user in <strong>Redis,<\/strong> and not in the memory of the process. In this way our application will be much easier to scale.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"La-aplicacion-de-demostracion-que-necesita-autenticacion\"><\/span>The demo application that needs authentication<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>For demonstration purposes, let&#039;s build an application that does just the following:<\/p>\n<ul>\n<li>expose a login form,<\/li>\n<li>expose two protected pages:\n<ul>\n<li>a profile page,<\/li>\n<li>secured notes<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"La-estructura-del-proyecto\"><\/span>The structure of the project<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>We are going to use the following structure:<\/p>\n<pre data-enlighter-language=\"php\" class=\"EnlighterJSRAW\">\u251c\u2500\u2500 app | \u251c\u2500\u2500 authentication | \u251c\u2500\u2500 note | \u251c\u2500\u2500 user | \u251c\u2500\u2500 index.js | \u2514\u2500\u2500 layout.hbs \u251c\u2500\u2500 config | \u2514\u2500\u2500 index.js \u251c\u2500\u2500 index.js \u2514\u2500\u2500 package.json\n<\/pre>\n<p>As you can see, we will organize the files and directories around the characteristics. We will have a user page, a notes page and some functions related to authentication.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"El-flujo-de-autenticacion-Nodejs\"><\/span>The Node.js authentication flow<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Our goal is to implement the following authentication flow in our application using <strong>Passport.js:<\/strong><\/p>\n<ol>\n<li>User enters username and password<\/li>\n<li>The application checks if they match.<\/li>\n<li>If they match, send a header <strong>Set-Cookie<\/strong> to be used to authenticate other pages.<\/li>\n<li>When the user visits pages of the same domain, the previously configured cookie will be added to all requests<\/li>\n<li>Authenticate restricted pages with this cookie.<\/li>\n<\/ol>\n<p>To configure an authentication strategy like this in a Node.js application using Passport.js, follow these three steps:<\/p>\n<h4><span class=\"ez-toc-section\" id=\"Paso-1-Configuracion-de-Express\"><\/span>Step 1: Express Configuration<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>We are going to use Express for the server framework.<\/p>\n<pre data-enlighter-language=\"php\" class=\"EnlighterJSRAW\">\/\/ file: app \/ index.js const express = require (&#039;express&#039;) const passport = require (&#039;passport&#039;) const session = require (&#039;express-session&#039;) const RedisStore = require (&#039;connect-redis&#039;) ( session) const app = express () app.use (session ({store: new RedisStore ({url: config.redisStore.url}), secret: config.redisStore.secret, resave: false, saveUninitialized: false})) app .use (passport.initialize ()) app.use (passport.session ())\n<\/pre>\n<h5><span class=\"ez-toc-section\" id=\"%C2%BFQue-hicimos-aqui\"><\/span>What did we do here?<span class=\"ez-toc-section-end\"><\/span><\/h5>\n<p>First of all, we require all the dependencies that session management needs. After that, we have created a new instance of the module <strong>express-session,<\/strong> which will store our sessions.<\/p>\n<p>For the backup store, we are using <strong>Redis,<\/strong> but you can use any other, like <em>MySQL<\/em> or <em>MongoDB.<\/em><\/p>\n<h4><span class=\"ez-toc-section\" id=\"Paso-2-Configuracion-de-Passportjs-para-Nodejs\"><\/span>Step 2: Setting up Passport.js for Node.js<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>Passport.js is a great example of a library that uses plugins. In this tutorial of <strong>passport.js,<\/strong> we are adding the module <strong>passport-local<\/strong> which enables easy integration of a simple local authentication strategy using usernames and passwords.<\/p>\n<p>For the sake of simplicity, in this example, we are not using a second backing store, but only an in-memory user instance. In real life applications, <strong>findUser<\/strong> it would look up a user in a database.<\/p>\n<pre data-enlighter-language=\"php\" class=\"EnlighterJSRAW\">\/\/ file: app \/ authenticate \/ init.js const passport = require (&#039;passport&#039;) const bcrypt = require (&#039;bcrypt&#039;) const LocalStrategy = require (&#039;passport-local&#039;). Strategy const user = {username: &#039;test -user &#039;, passwordHash:&#039; bcrypt-hashed-password &#039;, id: 1} passport.use (new LocalStrategy ((username, password, done) =&gt; {findUser (username, (err, user) =&gt; {if (err) ) {return done (err)} \/\/ User not found if (! user) {return done (null, false)} \/\/ Always use hashed passwords and fixed-time comparisons bcrypt.compare (password, user.passwordHash, (err , isValid) =&gt; {if (err) {return done (err)} if (! isValid) {return done (null, false)} return done (null, user)})})}))\n<\/pre>\n<p>\nOnce the returns of <strong>findUser<\/strong> with our user object all that&#039;s left is to compare the user&#039;s hash password and the actual password to see if there is a match. Always store hashed passwords and use fixed time comparison to avoid time attacks.<\/p>\n<p>If it&#039;s a match, we allow the user to enter: <strong>return done (null, user)<\/strong> (returning the user the Passport), if not we return an unauthorized error (returning nothing to the Passport- <strong>return done (null)<\/strong>).<\/p>\n<h4><span class=\"ez-toc-section\" id=\"Paso-3-Agregar-puntos-finales-protegidos\"><\/span>Step 3: Add protected endpoints<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>To add protected endpoints, we are leveraging the pattern of <strong>middleware<\/strong> what do you use <strong>Express.<\/strong> For that, we are going to create the <strong>middleware<\/strong> authentication first:<\/p>\n<pre data-enlighter-language=\"php\" class=\"EnlighterJSRAW\">\/\/ file: app \/ authentication \/ middleware.js function authenticationMiddleware () {return function (req, res, next) {if (req.isAuthenticated ()) {return next ()} res.redirect (&#039;\/&#039;)}}\n<\/pre>\n<p>\nIt only has a role if the user is authenticated (has the correct cookies); just call the next <strong>middleware.<\/strong> Otherwise, it redirects to the page where the user can log in.<\/p>\n<p>Its use is as easy as adding a new middleware to the route definition.<\/p>\n<pre data-enlighter-language=\"php\" class=\"EnlighterJSRAW\">\/\/ file: app \/ user \/ init.js const passport = require (&#039;passport&#039;) app.get (&#039;\/ profile&#039;, passport.authenticationMiddleware (), renderProfile)\n<\/pre>\n<h5><span class=\"ez-toc-section\" id=\"Resumen-%E2%80%93-Autenticacion-con-Passportjs\"><\/span>Summary - Authentication with Passport.js<span class=\"ez-toc-section-end\"><\/span><\/h5>\n<p>In this Passport.js tutorial, you have learned how to add basic authentication to your Node.js application. Later, you can extend it with different authentication strategies, such as <strong>Facebook<\/strong> or <strong>Twitter<\/strong> You can find more strategies at <a rel=\"nofollow noopener noreferrer\" target=\"_blank\" href=\"http:\/\/passportjs.org\/\">http:\/\/passportjs.org\/<\/a>.<\/p>\n<\/p><\/div>","protected":false},"excerpt":{"rendered":"<p>Este tutorial de Passport.js te guiar\u00e1 a trav\u00e9s de los pasos para configurar una estrategia de autenticaci\u00f3n Node.js local utilizando Redis. Aprender\u00e1s a crear una interfaz de autenticaci\u00f3n con Passport.js,&#8230;<\/p>","protected":false},"author":1,"featured_media":95583,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1374],"tags":[1411],"class_list":["post-95582","post","type-post","status-publish","format-standard","has-post-thumbnail","category-javascript","tag-twitter"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.0 (Yoast SEO v28.2) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Node Hero \u2013 Node.js Autenticaci\u00f3n utilizando Passport.js - R Marketing Digital<\/title>\n<meta name=\"description\" content=\"Este tutorial de Passport.js te guiar\u00e1 a trav\u00e9s de los pasos para configurar una estrategia de autenticaci\u00f3n Node.js local utilizando Redis. Aprender\u00e1s a\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/rmarketingdigital.com\/en\/javascript\/node-hero-node-js-autenticacion-utilizando-passport-js\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Node Hero \u2013 Node.js Autenticaci\u00f3n utilizando Passport.js\" \/>\n<meta property=\"og:description\" content=\"Este tutorial de Passport.js te guiar\u00e1 a trav\u00e9s de los pasos para configurar una estrategia de autenticaci\u00f3n Node.js local utilizando Redis. Aprender\u00e1s a\" \/>\n<meta property=\"og:url\" content=\"https:\/\/rmarketingdigital.com\/en\/javascript\/node-hero-node-js-autenticacion-utilizando-passport-js\/\" \/>\n<meta property=\"og:site_name\" content=\"R Marketing Digital\" \/>\n<meta property=\"article:published_time\" content=\"2022-07-30T03:14:04+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/rmarketingdigital.com\/wp-content\/uploads\/2020\/12\/passportjs-logo-preview-2364305.png\" \/>\n\t<meta property=\"og:image:width\" content=\"400\" \/>\n\t<meta property=\"og:image:height\" content=\"277\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"R Marketing Digital\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/rmarketingdigital.com\\\/javascript\\\/node-hero-node-js-autenticacion-utilizando-passport-js\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/rmarketingdigital.com\\\/javascript\\\/node-hero-node-js-autenticacion-utilizando-passport-js\\\/\"},\"author\":{\"name\":\"R Marketing Digital\",\"@id\":\"https:\\\/\\\/rmarketingdigital.com\\\/#\\\/schema\\\/person\\\/7c0d9782b2977b840b3740f00c69a73e\"},\"headline\":\"Node Hero \u2013 Node.js Autenticaci\u00f3n utilizando Passport.js\",\"datePublished\":\"2022-07-30T03:14:04+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/rmarketingdigital.com\\\/javascript\\\/node-hero-node-js-autenticacion-utilizando-passport-js\\\/\"},\"wordCount\":839,\"image\":{\"@id\":\"https:\\\/\\\/rmarketingdigital.com\\\/javascript\\\/node-hero-node-js-autenticacion-utilizando-passport-js\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/rmarketingdigital.com\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/passportjs-logo-preview-2364305.png\",\"keywords\":[\"Twitter\"],\"articleSection\":[\"Javascript\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/rmarketingdigital.com\\\/javascript\\\/node-hero-node-js-autenticacion-utilizando-passport-js\\\/\",\"url\":\"https:\\\/\\\/rmarketingdigital.com\\\/javascript\\\/node-hero-node-js-autenticacion-utilizando-passport-js\\\/\",\"name\":\"Node Hero \u2013 Node.js Autenticaci\u00f3n utilizando Passport.js - R Marketing Digital\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/rmarketingdigital.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/rmarketingdigital.com\\\/javascript\\\/node-hero-node-js-autenticacion-utilizando-passport-js\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/rmarketingdigital.com\\\/javascript\\\/node-hero-node-js-autenticacion-utilizando-passport-js\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/rmarketingdigital.com\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/passportjs-logo-preview-2364305.png\",\"datePublished\":\"2022-07-30T03:14:04+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/rmarketingdigital.com\\\/#\\\/schema\\\/person\\\/7c0d9782b2977b840b3740f00c69a73e\"},\"description\":\"Este tutorial de Passport.js te guiar\u00e1 a trav\u00e9s de los pasos para configurar una estrategia de autenticaci\u00f3n Node.js local utilizando Redis. Aprender\u00e1s a\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/rmarketingdigital.com\\\/javascript\\\/node-hero-node-js-autenticacion-utilizando-passport-js\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/rmarketingdigital.com\\\/javascript\\\/node-hero-node-js-autenticacion-utilizando-passport-js\\\/#primaryimage\",\"url\":\"https:\\\/\\\/rmarketingdigital.com\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/passportjs-logo-preview-2364305.png\",\"contentUrl\":\"https:\\\/\\\/rmarketingdigital.com\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/passportjs-logo-preview-2364305.png\",\"width\":400,\"height\":277,\"caption\":\"passportjs-logo-preview-2364305-2454360-png\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/rmarketingdigital.com\\\/#website\",\"url\":\"https:\\\/\\\/rmarketingdigital.com\\\/\",\"name\":\"R Marketing Digital\",\"description\":\"Agencia SEO | Publicidad redes sociales | Community Management\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/rmarketingdigital.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/rmarketingdigital.com\\\/#\\\/schema\\\/person\\\/7c0d9782b2977b840b3740f00c69a73e\",\"name\":\"R Marketing Digital\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/c5599c203e0120b8ccbff4666af86f35f9b3dcad468a8bc6295313a3964a80be?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/c5599c203e0120b8ccbff4666af86f35f9b3dcad468a8bc6295313a3964a80be?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/c5599c203e0120b8ccbff4666af86f35f9b3dcad468a8bc6295313a3964a80be?s=96&d=mm&r=g\",\"caption\":\"R Marketing Digital\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Node Hero - Node.js Authentication using Passport.js - R Marketing Digital","description":"This Passport.js tutorial will walk you through the steps to configure a local Node.js authentication strategy using Redis. You will learn to","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/rmarketingdigital.com\/en\/javascript\/node-hero-node-js-autenticacion-utilizando-passport-js\/","og_locale":"en_US","og_type":"article","og_title":"Node Hero \u2013 Node.js Autenticaci\u00f3n utilizando Passport.js","og_description":"Este tutorial de Passport.js te guiar\u00e1 a trav\u00e9s de los pasos para configurar una estrategia de autenticaci\u00f3n Node.js local utilizando Redis. Aprender\u00e1s a","og_url":"https:\/\/rmarketingdigital.com\/en\/javascript\/node-hero-node-js-autenticacion-utilizando-passport-js\/","og_site_name":"R Marketing Digital","article_published_time":"2022-07-30T03:14:04+00:00","og_image":[{"width":400,"height":277,"url":"https:\/\/rmarketingdigital.com\/wp-content\/uploads\/2020\/12\/passportjs-logo-preview-2364305.png","type":"image\/png"}],"author":"R Marketing Digital","twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/rmarketingdigital.com\/javascript\/node-hero-node-js-autenticacion-utilizando-passport-js\/#article","isPartOf":{"@id":"https:\/\/rmarketingdigital.com\/javascript\/node-hero-node-js-autenticacion-utilizando-passport-js\/"},"author":{"name":"R Marketing Digital","@id":"https:\/\/rmarketingdigital.com\/#\/schema\/person\/7c0d9782b2977b840b3740f00c69a73e"},"headline":"Node Hero \u2013 Node.js Autenticaci\u00f3n utilizando Passport.js","datePublished":"2022-07-30T03:14:04+00:00","mainEntityOfPage":{"@id":"https:\/\/rmarketingdigital.com\/javascript\/node-hero-node-js-autenticacion-utilizando-passport-js\/"},"wordCount":839,"image":{"@id":"https:\/\/rmarketingdigital.com\/javascript\/node-hero-node-js-autenticacion-utilizando-passport-js\/#primaryimage"},"thumbnailUrl":"https:\/\/rmarketingdigital.com\/wp-content\/uploads\/2020\/12\/passportjs-logo-preview-2364305.png","keywords":["Twitter"],"articleSection":["Javascript"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/rmarketingdigital.com\/javascript\/node-hero-node-js-autenticacion-utilizando-passport-js\/","url":"https:\/\/rmarketingdigital.com\/javascript\/node-hero-node-js-autenticacion-utilizando-passport-js\/","name":"Node Hero - Node.js Authentication using Passport.js - R Marketing Digital","isPartOf":{"@id":"https:\/\/rmarketingdigital.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/rmarketingdigital.com\/javascript\/node-hero-node-js-autenticacion-utilizando-passport-js\/#primaryimage"},"image":{"@id":"https:\/\/rmarketingdigital.com\/javascript\/node-hero-node-js-autenticacion-utilizando-passport-js\/#primaryimage"},"thumbnailUrl":"https:\/\/rmarketingdigital.com\/wp-content\/uploads\/2020\/12\/passportjs-logo-preview-2364305.png","datePublished":"2022-07-30T03:14:04+00:00","author":{"@id":"https:\/\/rmarketingdigital.com\/#\/schema\/person\/7c0d9782b2977b840b3740f00c69a73e"},"description":"This Passport.js tutorial will walk you through the steps to configure a local Node.js authentication strategy using Redis. You will learn to","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/rmarketingdigital.com\/javascript\/node-hero-node-js-autenticacion-utilizando-passport-js\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/rmarketingdigital.com\/javascript\/node-hero-node-js-autenticacion-utilizando-passport-js\/#primaryimage","url":"https:\/\/rmarketingdigital.com\/wp-content\/uploads\/2020\/12\/passportjs-logo-preview-2364305.png","contentUrl":"https:\/\/rmarketingdigital.com\/wp-content\/uploads\/2020\/12\/passportjs-logo-preview-2364305.png","width":400,"height":277,"caption":"passportjs-logo-preview-2364305-2454360-png"},{"@type":"WebSite","@id":"https:\/\/rmarketingdigital.com\/#website","url":"https:\/\/rmarketingdigital.com\/","name":"R Digital Marketing","description":"SEO Agency | Advertising social networks | Community Management","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/rmarketingdigital.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/rmarketingdigital.com\/#\/schema\/person\/7c0d9782b2977b840b3740f00c69a73e","name":"R Digital Marketing","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/c5599c203e0120b8ccbff4666af86f35f9b3dcad468a8bc6295313a3964a80be?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/c5599c203e0120b8ccbff4666af86f35f9b3dcad468a8bc6295313a3964a80be?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c5599c203e0120b8ccbff4666af86f35f9b3dcad468a8bc6295313a3964a80be?s=96&d=mm&r=g","caption":"R Marketing Digital"}}]}},"_links":{"self":[{"href":"https:\/\/rmarketingdigital.com\/en\/wp-json\/wp\/v2\/posts\/95582","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rmarketingdigital.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rmarketingdigital.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rmarketingdigital.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rmarketingdigital.com\/en\/wp-json\/wp\/v2\/comments?post=95582"}],"version-history":[{"count":0,"href":"https:\/\/rmarketingdigital.com\/en\/wp-json\/wp\/v2\/posts\/95582\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/rmarketingdigital.com\/en\/wp-json\/wp\/v2\/media\/95583"}],"wp:attachment":[{"href":"https:\/\/rmarketingdigital.com\/en\/wp-json\/wp\/v2\/media?parent=95582"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rmarketingdigital.com\/en\/wp-json\/wp\/v2\/categories?post=95582"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rmarketingdigital.com\/en\/wp-json\/wp\/v2\/tags?post=95582"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}