From the course: Advanced Express
Introduction to Passport
From the course: Advanced Express
Introduction to Passport
- [Narrator] Passport is the most widely-used authentication module for Node.js. Conceptually, Passport provides an authenticate function. This function uses a so-called strategy to authenticate the user. Strategies are pluggable authentication modules that can be installed separately. Through these strategies, Passport covers a lot of back ends or use cases from local authentication that is mostly used to authenticate against the local database to strategies for a variety of third-party systems, including single sign-on providers and logins via social media concepts, like Facebook, or other exotic systems Shoplet. Right now, there are over 500 strategies available. Once Overview successfully authenticated, Passport also takes care of storing the user in the session, and restoring it for every request. To use Passport in Express, it needs to be hooked into the application with, you might've guessed it, two middle definitions. What do these two middle functions do? First we have initialize, it returns a middleware function that uses the request object to store passport internal data in. And then, we need passport dot session. It looks for previously serialized user in the current session and uses a provided deserialization function to provide the user in request dot user to all following middlewares and routes. In the next videos, we are going to add Passport to our sample project and we will create a strategy to authenticate users against the database.
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
Understanding cookies and sessions3m 54s
-
(Locked)
Adding cookies and sessions to Express5m
-
(Locked)
Inspecting the session object2m 18s
-
Introduction to Passport1m 39s
-
(Locked)
Adding Passport to Express3m 55s
-
(Locked)
Setting up an authentication strategy for Passport5m 18s
-
(Locked)
Serializing and deserializing users3m 25s
-
(Locked)
Creating a login form with Passport5m 14s
-
(Locked)
Providing a logout link2m 1s
-
(Locked)
Authentication vs. authorization1m 23s
-
(Locked)
Protecting routes3m 35s
-
-
-
-