In the last section we got a high level overview of how a lot is going to be working inside of our application
at this point.
I want to start to talk a little bit more about how we're going to approach this problem.
So we're going to be using a helper library called Passport J.S. to help us create this authentication
flow.
In particular the passport library is going to automatically take care of a couple of different steps
inside of here.
That's going to make our lives just a little bit easier to make sure that it's clear exactly what passport
is going to be doing for us.
I made a little change to this diagram.
So let's take a glance at it.
OK.
So very clearly everything inside this yellow box right here this is essentially what passport is going
to be automating for us or what it's going to be kind of helping us pull off without having to write
a lot of boilerplate code.
Now before we just kind of dive right in and make use of passport there's two big issues around it that
I want to tell you about right now at the very get go.
Now the reason I'm telling you about these two issues around passport is that they are very common complaints
here about passport all the time.
So I can tell you about these two very common complaints so that if we start making use of passport
and you're sitting there thinking like man this passport stuff is just garbage.
I want you to be really aware that you probably are voicing a complaint that many other people have
as well.
So here's the two big things that passport doesn't quite do so well.
First off passport does help us automate this entire flow.
But the issue is that it does require us to kind of reach in to some very specific points in the flow
like let's just imagine like right here and right here and right here it requires us to reach in and
add a little bit of code to make those steps work nicely.
Some of the words.
It automates vast majorities of the flow but not the entire thing.
The reason that's a problem is that sometimes when you're setting up a cloth you get the feeling that
you don't really understand the overall big picture and it feels like you're just kind of adding in
some weird code in some weird places without having a good understanding of how it all fits together.
So as we go through the setup and the passport's setup I will do my darndest to make sure that it's
really clear what every line of code we're adding is doing inside this flow.
But if you ever feel like you really don't have a good sense of the big picture hey that's totally fine.
Again very common complaint something that a lot of people end up saying about passport.
Now the second big issue with passport is just the inherent confusion and how the library is structured.
So let me tell you exactly what I mean by that.
Up to this point inside this video stuff like last minute and a half I've been saying just passport
passport passport over and over again.
But in reality when we make use of passport we are actually installing at least two different libraries.
So let's talk about what those two libraries are OCHA.
So in this diagram it has to kind of like things on it.
We're just focused on the one on the left right now so just ignore the stuff on the right.
So when we make use of passport we are actually installing at least two separate libraries.
The first library is called Just passport that's all.
It's just called passport.
The core passport library or the core passport module is a set of very general functions and objects
and helpers that make authentication work nicely inside of Express.
So some very generic logic that can handle the idea of authentication with Express to actually implement
a authentication flow with a very specific provider.
However when I say provider I mean like specifically authentication with Google or with e-mail password
or with Facebook or get or whoever else we install what are called Passport strategies.
So there's many different strategies out in the world and each individual strategy helps you center
set up authentication with one very specific provider.
So this is a point of confusion.
Number two with passport understanding what you're actually installing.
You always install the base passport module and then you also install at least one passport strategy
that will help you handle authentication with one specific provider.
Now if you want to do multiple types of authentication inside of your application if you want to have
authentication with Google and Facebook and Linked In and Twitter that's totally fine.
It just means that you're going to install four separate strategies and wire all those up inside of
your application as well for our application for our app.
We're only handling sign up with Google.
So we are going to be installing exactly one passport strategy.
OK.
So overall that's the two big complaints or kind of the two big like warning signs I'm going to put
out there for you with passport so Warning Number one is sometimes it feels like we don't have a good
sense of the overall flow of passport and then worrying number two is that we always have to install
at least one of these strategies and hook it up inside of our application.
Now before we close this out very quickly I want to pull out the passport documentation and just let
you take a quick glance at it and I bet you might get a sense of these two complaints of spoken about
inside of here.
So in a new browser tab I'm going to do a search for passport G-S and then we'll click on hopefully
the first link that pops up which is Passport G-S dot org.
Now when you come here you're going to immediately see the word strategies all over the place.
So you see strategies strategies and then scroll down a little bit.
And while the war strategy is just all over the place strategies.
So remember a strategy is a module that helps you authenticate with one very specific provider.
So let's first take a look at the documentation page so you can click on documentation over here and
you get this just kind of like very general basic overview on what passport's doing for you.
You know if you want to feel free to read through this stuff.
But I kind of feel like you will agree with me that it feels like it's not really giving you the overall
picture of what's going on.
You know I don't really see any diagram here that says hey here is like a very broad overview of exactly
what's happening in very straightforward language.
Now the first paragraph on here it does give you like you know some reason the idea of what's going
on.
But again I feel like it's just not super clear.
Now the other thing I want to show you very quickly is the strategy's page.
So if we go to strategies you can see a list of all the different providers or all the different strategies
you can hook up to passports.
So looking through here like here's passports Spotify so doing.
Oh all through Spotify.
So we can click on the strategy and it will take us to a hub repository that gives us some documentation
or some idea of how to handle Passport authentication with Spotify.
And so when we finished this course or when we finish wiring up Passport authentication you absolutely
could come back through and wire the passport Spotify just as easily and then allow your users to sign
up as Spotify as well.
So when we go through the google stuff it's going to be very similar to how Spotify works and how Facebook
and LinkedIn and all these other providers work as well.
So really we're going to focus on this one Google provider and then you in theory should be able to
easily come back and add in other providers if you want to.
Okay.
So I think that's enough talking about passports for this section.
Let's continue into the next section and we're going to install passport and start to wired up inside
of our application.
So I'll see you in just a sec.