1 00:00:00,150 --> 00:00:07,920 In the previous video, we have all rated the configurator method available in Bring Security to customize 2 00:00:07,920 --> 00:00:11,090 and provide user details ASPO requirement. 3 00:00:11,100 --> 00:00:18,360 And at the same time we also configure multiple users with the name admin user along with their authorities. 4 00:00:18,390 --> 00:00:26,040 Now, with this configuration, we don't need these credentials mentioned in the application or properties 5 00:00:26,070 --> 00:00:29,990 because they are absolutely no reason to bring security. 6 00:00:30,120 --> 00:00:34,200 Always consider these users as a first priority. 7 00:00:34,230 --> 00:00:40,350 If we don't customize this method, then it will go and look for the credentials in the application 8 00:00:40,380 --> 00:00:41,120 or properties. 9 00:00:41,140 --> 00:00:48,900 I want to show you either way on how we can provide and customize user detail to spring security in 10 00:00:48,900 --> 00:00:50,420 this video to further. 11 00:00:50,520 --> 00:00:58,390 First, let's amend the method that we have written previously and now we have the same method already, 12 00:00:58,680 --> 00:01:00,470 but in a different manner. 13 00:01:00,660 --> 00:01:04,700 Previously we used in-memory authentication. 14 00:01:04,830 --> 00:01:13,650 Now, instead of that, I am trying to use a in-memory user details manager, which by default provided 15 00:01:13,650 --> 00:01:15,840 by the spring security vendor. 16 00:01:15,840 --> 00:01:21,030 We want to store the user details inside memory of our application. 17 00:01:21,060 --> 00:01:29,340 So in this scenario, memory user details manager is an implementation of user details, which I will 18 00:01:29,460 --> 00:01:38,670 use inside this method once we ensure that we have to build the users that we want to build for our 19 00:01:38,670 --> 00:01:39,520 application. 20 00:01:39,570 --> 00:01:48,870 If we see previously I was saying we have user user details and user details, services, all such interfaces, 21 00:01:48,870 --> 00:01:55,400 classes available inside our security will be discussing about all this in detail in the coming videos. 22 00:01:55,470 --> 00:02:03,690 But for now you can understand that using user we call with user name method where we pass the user 23 00:02:03,690 --> 00:02:13,470 name, password and authority details and calling build on this code will give the user details associated 24 00:02:13,470 --> 00:02:14,460 with this user. 25 00:02:14,730 --> 00:02:22,890 Similarly, we are building another user called user one with a detailed user password and authorities 26 00:02:22,890 --> 00:02:29,680 as what the users we have to pass to the user details service by calling create user. 27 00:02:29,820 --> 00:02:38,520 So since I have declared to users here, I have to pass both of them to create user two times post that 28 00:02:38,520 --> 00:02:47,280 I have to set this user detail service, which is of in-memory user details manager inside my user detail, 29 00:02:47,290 --> 00:02:49,950 service of authentication manager build. 30 00:02:50,130 --> 00:02:56,940 With this it will be work similarly like we have seen in the previous video. 31 00:02:57,270 --> 00:03:00,950 But the only thing right now here missing is password encoder. 32 00:03:01,290 --> 00:03:08,400 Let's try to see what will happen if we don't have any password encoder whenever we try to customize 33 00:03:08,400 --> 00:03:10,670 users as per the requirement. 34 00:03:10,920 --> 00:03:17,190 So I'm saving this configuration, going to bring good starter class, putting this over the server 35 00:03:17,620 --> 00:03:18,810 stats perfectly. 36 00:03:18,990 --> 00:03:24,900 Now I'm clearing the console to see whatever that we get calling my account. 37 00:03:25,050 --> 00:03:33,480 And since it's a security redirect login page and asking my undervalued currency, I mean, one, two, 38 00:03:33,480 --> 00:03:40,530 three, four, five, you can see that we have an error thrown and the details of error. 39 00:03:40,530 --> 00:03:44,080 Each is no password and kodet mapped. 40 00:03:44,400 --> 00:03:47,280 That means spring security framework. 41 00:03:47,460 --> 00:03:53,880 All of us will expect a password and to be mapped are custom user details. 42 00:03:54,210 --> 00:03:56,550 We have configured result this error. 43 00:03:56,730 --> 00:04:01,140 Let's start this over and go to a configuration class here. 44 00:04:01,380 --> 00:04:10,290 We have to create a bit of time password encoder and I am returning no password encoder as the type 45 00:04:10,290 --> 00:04:11,880 for this being here. 46 00:04:12,000 --> 00:04:16,860 My spring security sends it to find a bit of my password quarter. 47 00:04:17,070 --> 00:04:25,320 It takes this as a default password encoder that it has to assume for this user details custom configurations 48 00:04:25,560 --> 00:04:28,230 that we have done here with error. 49 00:04:28,500 --> 00:04:30,960 We should have solved that exception. 50 00:04:31,110 --> 00:04:36,870 Let's try to start our application again to my account. 51 00:04:37,140 --> 00:04:43,380 It's time entering admin one, two, three, four file and we've gotten spun successfully. 52 00:04:43,380 --> 00:04:44,710 That's one leanly. 53 00:04:44,910 --> 00:04:52,110 We can see the same response using the other credentials user that we have defined. 54 00:04:52,290 --> 00:04:53,700 Let's see that one also. 55 00:04:53,880 --> 00:04:58,290 Oh, entering the details of user followed by his password. 56 00:04:58,530 --> 00:04:59,650 It is one, two, three, four. 57 00:05:00,120 --> 00:05:10,890 Now, at question is we also learned another way of defining our users and letting the default implementation 58 00:05:10,890 --> 00:05:15,700 of user detail service along with the password and Encoder Bassingthwaighte. 59 00:05:16,020 --> 00:05:18,720 So we have seen total two ways. 60 00:05:18,930 --> 00:05:26,130 One is by using the in-memory authentication, which is of like some people may feel like, I'm not 61 00:05:26,130 --> 00:05:33,150 able to understand what is happening here, but if we want to have some clear code, I would always 62 00:05:33,150 --> 00:05:42,030 recommend you to use in-memory user details manager where we first defined the users and pass them to 63 00:05:42,030 --> 00:05:48,150 user details service, which will be used eventually to authenticate unmanageability. 64 00:05:48,510 --> 00:05:57,000 We also have been created by password in order for this custom user details implementation that we have 65 00:05:57,000 --> 00:05:58,740 done here in this class. 66 00:05:58,920 --> 00:05:59,540 Thank you. 67 00:05:59,550 --> 00:06:01,620 And see you in the next week by.