WEBVTT 0 00:00.350 --> 00:00.990 All right guys. 1 00:01.020 --> 00:03.450 Welcome to a brand new module. 2 00:03.510 --> 00:10.980 And in this module we're going to tackle the topic of authentication. And it's something that is often 3 00:10.980 --> 00:15.390 thought of as incredibly complicated but it doesn't have to be. 4 00:15.420 --> 00:21.750 And we're going to take it step by step from beginning to end so that you get an overview of the entire 5 00:21.750 --> 00:24.540 process of setting up authentication from scratch. 6 00:25.290 --> 00:28.120 So why do we need to authenticate? 7 00:28.140 --> 00:35.700 Well, as we're creating our website or web app for users to use then these users are going to start 8 00:35.730 --> 00:38.700 generating data in the website. 9 00:38.790 --> 00:43.210 They might like certain posts, they might interact with other users, 10 00:43.260 --> 00:46.960 there might be messages created or recipes created. 11 00:46.980 --> 00:53.820 There's always going to be some user data created. And in order to associate those pieces of data with 12 00:53.820 --> 01:00.360 individual users, we need to create an account for each user so that they would sign up to our website 13 01:00.420 --> 01:07.110 using a username and password and we would essentially create kind of like an ID card for them to 14 01:07.110 --> 01:15.120 uniquely identify them on our database and to save all of the data that they generate onto that account. 15 01:15.120 --> 01:20.640 So the next time that they come back onto the website they'll be able to use their username and password 16 01:21.060 --> 01:28.490 and log into our website and be able to access all of those possibly private pieces of information. 17 01:28.500 --> 01:33.480 So this way you don't end up with everybody being able to see you know what private messages you're 18 01:33.480 --> 01:37.670 sending around on Facebook or see your direct messages on Twitter. 19 01:37.680 --> 01:39.330 So that's pretty simple. 20 01:39.330 --> 01:45.390 Now the other reason why you might want to add authentication to your website is to restrict access 21 01:45.660 --> 01:50.070 to certain areas of the website depending on the status of the user. 22 01:50.070 --> 01:57.810 So for example if you were Spotify or Netflix and you charge a subscription for accessing certain parts 23 01:57.810 --> 02:03.570 of the website then once the user pays, you have to update their account in your database to say that 24 02:03.570 --> 02:10.800 they have paid and they'll be allowed to access the TV shows or songs that they're entitled to. 25 02:10.800 --> 02:18.540 So those are some of the reasons why you might want to add authentication to your website. But authentication 26 02:18.540 --> 02:21.030 can be done in a number of ways. 27 02:21.060 --> 02:27.690 Creating a website where we sign up and login users seems simple enough but the difficult part of 28 02:27.690 --> 02:33.290 authentication comes from how secure you're going to make your website. 29 02:33.420 --> 02:41.680 And we're going to tackle this problem of authentication by going through the different levels of security. 30 02:41.820 --> 02:48.000 So we're going to go from very basic creating an account, adding the user to our database, saving their 31 02:48.000 --> 02:54.850 username and password to enable them to log in, all the way up to covering things such as OAuth and social 32 02:54.870 --> 03:01.710 logins including creating things such as sessions and cookies and hashing and encrypting passwords. 33 03:01.890 --> 03:07.260 And it's going to be more than you'd ever want to know about this topic but it's really really important 34 03:07.290 --> 03:12.990 that you learn it in the beginning because later on once you've understood and you've built authentication 35 03:13.050 --> 03:19.290 from the bottom up then I'm going to show you some ways of simplifying and making your life easier 36 03:19.380 --> 03:22.130 using third party libraries like Passport. 37 03:22.200 --> 03:27.090 So we're going to learn how to progress from essentially a website that's basically secured with a 38 03:27.090 --> 03:34.050 chito to something that is a lot more serious and more consistent with industry standards of good 39 03:34.110 --> 03:35.670 security on a website. 40 03:36.030 --> 03:44.130 So if you're not interested in learning how to authenticate users from the very basics all the way up 41 03:44.130 --> 03:51.030 to the most complicated if you just want to skip ahead right to the end where we cover auth using third 42 03:51.030 --> 03:55.840 party social loggins such as Google or Facebook, then feel free to do that. 43 03:55.870 --> 04:02.130 But I strongly strongly recommend that you follow along the entire tutorial not only because there's 44 04:02.130 --> 04:03.720 some pretty good jokes coming up 45 04:03.780 --> 04:10.590 if I might say so myself, but also because it will help you build a foundation of knowledge around this 46 04:10.590 --> 04:15.090 topic so that when you see it in the wild you won't be stumped. 47 04:15.120 --> 04:21.540 So once you're ready we're going to get started building a website that keeps secrets. 48 04:21.540 --> 04:23.640 Makes sense right? Authentication. 49 04:24.000 --> 04:30.900 So there is a app called Whisper that you might have come across and it's a really simple concept basically 50 04:30.900 --> 04:40.200 allows people to submit their secrets anonymously. So whatever they post are not associated with a email 51 04:40.260 --> 04:46.650 or a user name and it means that people can express themselves I guess more freely. 52 04:46.650 --> 04:47.930 It's quite a fun website 53 04:47.970 --> 04:52.680 and this is what we're going to try and replicate by the end of this module. 54 04:52.710 --> 04:56.610 So the structure of our website is really really simple. 55 04:56.640 --> 05:05.280 It has a home page which has two buttons that allows you to either go towards register or go towards 56 05:05.280 --> 05:11.490 log in and once the user has been registered or logged in and they have been authenticated then they 57 05:11.490 --> 05:14.600 are able to access the secrets page. 58 05:14.700 --> 05:20.610 So I've kept the remainder of the website pretty simple because we're going to be focusing on a pretty 59 05:20.610 --> 05:21.770 complex topic. 60 05:21.810 --> 05:28.530 So I've created some starting files for you to download so that we can focus our efforts on learning 61 05:28.560 --> 05:33.100 authentication and not get distracted by things like Bootstrap and styling. 62 05:33.150 --> 05:39.380 So once you are ready, head over to the next lesson and download the starting files and then we're gonna get 63 05:39.380 --> 05:45.060 started with our level 1 security authentication. So I'll see you there.