All right guys, welcome to a brand new module. 1
And in this module we're going to tackle the topic of Authentication. 2
And it's something that is often thought of as incredibly complicated, 3
but it doesn't have to be. 4
And we're going to take it step by step from beginning to end so that you get an overview of the entire 5
process of setting up authentication from scratch. 6
So why do we need to authenticate? 7
Well, as we're creating our website or web app for users to use, then these users are going to start 8
generating data in the website. 9
They might like certain posts, they might interact with other users, there might be messages created 10
or recipes created, 11
there's always going to be some user data created. 12
And in order to associate those pieces of data with individual users, we need to create an Account 13
for each user. 14
So they would sign up to our website using a username and a password. 15
And we would essentially create kind of like an ID card for them to uniquely identify them on our database 16
and to save all of the data that they generate onto that account. 17
So the next time that they come back onto the website, they'll be able to use their username and password 18
and log in to our website and be able to access all of those possibly private pieces of information. 19
So this way you don't end up with everybody being able to see, you know, what private messages you're 20
sending around on Facebook or see your direct messages on Twitter. 21
So that's pretty simple. 22
Now, the other reason why you might want to add authentication to your website is to restrict access 23
to certain areas of the website, depending on the status of the user. 24
So for example, if you were Spotify or Netflix and you charge a subscription for accessing certain 25
parts of the website, then once the user pays, you have to update their account in your database to 26
say that they have paid and they'll be allowed to access the TV shows or songs that they're entitled 27
to. 28
Those are some of the reasons why you might want to add authentication to your website, but authentication 29
can be done in a number of ways. 30
Creating a website where we sign up and log in users seems simple enough, but the difficult part of 31
authentication comes from how secure you're going to make your website. 32
And we're going to tackle this problem of authentication by going through the different levels of security. 33
So we're going to go from very basic creating an account, adding the user to our database, saving 34
their username and password to enable them to log in all the way up to covering things such as OAuth 35
and social logins, including creating things such as sessions and cookies and hashing and encrypting 36
passwords and it's going to be more than you'd ever want to know about this topic, but it's really, 37
really important that you learn it in the beginning, because later on, once you've understood and 38
you've built authentication from the bottom up, then I'm going to show you some ways of simplifying 39
and making your life easier using third-party libraries like Passport. 40
So we're going to learn how to progress from essentially a website that's basically secured with a Cheeto 41
to something that is a lot more serious and more consistent with industry standards of good security 42
on a website. 43
If you're not interested in learning how to authenticate users from the very basics all the way up to 44
the most complicated, if you just want to skip ahead right to the end where we cover OAuth using third- 45
party social logins such as Google or Facebook, then feel free to do that. 46
But I strongly, strongly recommend that you follow along the entire tutorial, not only because there's 47
some pretty good jokes coming up, if I might say so myself, but also because it will help you build 48
a foundation of knowledge around this topic so that when you see it in the wild, you won't be stumped. 49
Once you're ready, we're going to get started building a website that keeps secrets. 50
Makes sense, right? 51
Authentication. 52
There is an app called Whisper that you might have come across, 53
and it's a really simple concept, that basically allows people to submit their secrets anonymously. 54
So whatever they post are not associated with a email or a username, and it means that people can express 55
themselves, I guess, more freely. 56
It's quite a fun website, and this is what we're going to try and replicate by the end of this module. 57
So the structure of our website is really, really simple. 58
It has a home page which has two buttons that allows you to. 59
Either go towards register or go towards login. 60
And once the user has been registered or logged in and they have been authenticated, then they are 61
able to access the secrets page. 62
So I've kept the remainder of the website pretty simple because we're going to be focusing on a pretty 63
complex topic. 64
So I've created some starting files for you to download so that we can focus our efforts on learning 65
authentication and not get distracted by things like Bootstrap and styling. 66
Once you're ready, head over to the next lesson, and then we're going to get started with our Level 1 67
Security Authentication. 68
So I'll see you there.