1
00:00:00,170 --> 00:00:06,750
In the previous video, we have created a database in the cloud and inside that database, we have created

2
00:00:06,750 --> 00:00:15,510
a couple of tables, which is users and authorities, and we also insert the user details like the user

3
00:00:15,510 --> 00:00:16,500
name is happy.

4
00:00:16,500 --> 00:00:21,750
And this password along with his authorities, which is it right now?

5
00:00:22,050 --> 00:00:30,450
Let's try to leverage the user details manager to connect to this database and do authentication of

6
00:00:30,450 --> 00:00:33,900
the user based upon the details that we are maintaining in the database.

7
00:00:34,020 --> 00:00:36,120
For that, let's go to our code.

8
00:00:36,440 --> 00:00:42,210
Very first thing that you have to do inside a project is you have to add the dependencies related to

9
00:00:42,540 --> 00:00:45,690
my school databases inside your.

10
00:00:46,280 --> 00:00:46,520
Com.

11
00:00:47,070 --> 00:00:50,460
So far that I have added these dependencies.

12
00:00:50,460 --> 00:00:58,160
One is Springboard Starter, A.B.C. and MySQL, Connector, Java and Springboard Starter, that AJP

13
00:00:58,350 --> 00:01:01,160
which will be using in the next coming radius.

14
00:01:01,200 --> 00:01:05,640
I have also added a couple of dependencies related to a lab.

15
00:01:05,760 --> 00:01:11,370
The reason is in the previous video I was showing the code inside a lab user details manager.

16
00:01:11,430 --> 00:01:15,440
In order to see that class, you should have dependencies mentioned in the Pumbaa.

17
00:01:16,080 --> 00:01:18,510
I missed mentioning this point in the previous video.

18
00:01:18,540 --> 00:01:24,540
That's why I'm stressing here again, if we want to check inside the code of lab user details manager,

19
00:01:24,780 --> 00:01:27,480
make sure you are adding these dependencies.

20
00:01:27,690 --> 00:01:35,340
And also we should add dependencies related to data masculine data AJP in order to connect to your database.

21
00:01:35,370 --> 00:01:42,060
Once we are added, these dependencies inside are undertaxing, will go to application DOT properties

22
00:01:42,060 --> 00:01:44,310
and give you a database detailed.

23
00:01:44,640 --> 00:01:51,120
Using these properties like the You Are the springboard application has to try to connect to connect

24
00:01:51,120 --> 00:01:52,350
to the database.

25
00:01:52,380 --> 00:01:58,800
So you should hojjati this in my school or that you should mention the hostname that we have seen in

26
00:01:58,800 --> 00:02:03,600
the database, followed by the database name that we have created.

27
00:02:03,690 --> 00:02:08,430
We have created it easy bank database inside our school database server.

28
00:02:08,580 --> 00:02:10,259
So that's where I have mentioned that.

29
00:02:10,770 --> 00:02:13,860
And at the same time, what is a username and password?

30
00:02:14,110 --> 00:02:17,250
Obviously this is one of the ways to connect database.

31
00:02:17,250 --> 00:02:23,070
And there are many ways if you are using a production or the application where you encrypt these details

32
00:02:23,130 --> 00:02:26,850
and are adding to environmental variables to database.

33
00:02:26,880 --> 00:02:34,740
But since this is focused on spring security, I'm just going then simple approach where we directly

34
00:02:34,740 --> 00:02:38,880
mention all our credentials and details inside our application properties.

35
00:02:38,970 --> 00:02:40,710
But this is not the commander.

36
00:02:40,890 --> 00:02:47,600
If we are trying to do this in the production or the application to post this spring, what application

37
00:02:47,610 --> 00:02:49,930
or database it has to connect.

38
00:02:50,220 --> 00:02:52,930
Now let's go to Project Security Config.

39
00:02:52,950 --> 00:02:59,430
So previously we are using in memory user details manager and in-memory user details.

40
00:02:59,430 --> 00:03:06,030
Manager is only useful in the scenarios where you want to demo something on your application is fine

41
00:03:06,030 --> 00:03:08,880
to how to store the user details inside.

42
00:03:08,880 --> 00:03:15,210
But in memory, the disadvantage of saving the details inside the memory is whenever you make changes

43
00:03:15,210 --> 00:03:22,380
to your user and you are restarting your server, the memory will act like a flash and volatile and

44
00:03:22,380 --> 00:03:28,410
whatever you have, initial values will be reset to those values after the start of the application.

45
00:03:28,500 --> 00:03:34,590
That's where if you don't want to affect the user, details change again and again.

46
00:03:34,860 --> 00:03:42,840
Whenever the restart happens, then it's always advisable to go with the user details manage the fact

47
00:03:42,840 --> 00:03:49,980
that I'm just going to come in this macur, for your reference, and now I don't have to create a user

48
00:03:49,980 --> 00:03:53,970
because I already have users created in the database.

49
00:03:54,120 --> 00:03:59,610
So in this scenario, I don't need all these things like creating end user setting that to use a detailed

50
00:03:59,610 --> 00:04:03,090
service and passing that the user interface to the framework.

51
00:04:03,600 --> 00:04:07,560
In this scenario, I just have to mention my framework.

52
00:04:07,770 --> 00:04:14,970
I am going to use JDA User Details Manager as my implementation offspring security.

53
00:04:15,270 --> 00:04:20,589
Go ahead and leverage that class to do authentication and authorizes.

54
00:04:20,820 --> 00:04:29,900
For that we just have to create a user detailed service being and framework automatically identifies.

55
00:04:29,910 --> 00:04:37,560
OK, this is a user detail service that I have to use and here we are telling we implement that user

56
00:04:37,560 --> 00:04:41,810
detail service by leveraging user details manager.

57
00:04:41,940 --> 00:04:45,570
So for that we also have to pass the data source.

58
00:04:45,720 --> 00:04:50,430
And don't worry, this data source will be created by spring security based upon the credentials that

59
00:04:50,430 --> 00:04:55,220
we have given inside the application that properties with this we are good.

60
00:04:55,270 --> 00:04:59,850
Go use our database values for authentication.

61
00:05:00,050 --> 00:05:07,960
But you may be wondering how this is working all Internet, if you go and see a user details manager,

62
00:05:08,360 --> 00:05:15,680
our framework will call law users money, user name, whatever, entering in the way that user name

63
00:05:15,680 --> 00:05:20,720
will come here and my GBC query will happen to the table.

64
00:05:20,870 --> 00:05:28,370
So if you say this is the query category you use to select the user details is the idea that we can

65
00:05:28,760 --> 00:05:32,460
select username password enabled from the table users.

66
00:05:32,690 --> 00:05:40,340
So since we want to go with the default implementation, we adhere to these standards and use the and

67
00:05:40,340 --> 00:05:45,210
created the table the same name, along with the same column names in the database.

68
00:05:45,250 --> 00:05:48,360
But now we are good to go and use this.

69
00:05:48,510 --> 00:05:58,520
Now let's try to start this over in debug more by going to the main application class and clicking Debuggers

70
00:05:58,520 --> 00:06:01,990
Java application and this will start the application.

71
00:06:02,000 --> 00:06:11,930
Now, this time I will put a breakpoint inside the method nor user by user name here so that I will

72
00:06:11,930 --> 00:06:18,770
show that framework calls this matter like in the previous video where we have seen that framework is

73
00:06:18,770 --> 00:06:23,800
calling for user by user name inside the memory user details manager.

74
00:06:24,350 --> 00:06:32,000
The reason is at that time we have mentioned user data service that we want to configure is in memory

75
00:06:32,000 --> 00:06:33,160
user details manager.

76
00:06:33,440 --> 00:06:40,060
But this time we said to the framework, go ahead and use the GBC user details manager.

77
00:06:40,250 --> 00:06:45,770
That is the reason framework will call this method inside the user details, Manisha.

78
00:06:46,130 --> 00:06:48,230
Now we have everything set and ready.

79
00:06:48,440 --> 00:06:56,610
Let's go to the browser in the browser to access the my account, which it will ask you the credentials.

80
00:06:57,260 --> 00:07:02,690
Now, let me enter the previous screenshots that we used to maintain in memory.

81
00:07:02,930 --> 00:07:06,730
So I'm just entering one, two, three, four, five.

82
00:07:07,430 --> 00:07:10,830
So it will throw at credentialled.

83
00:07:11,210 --> 00:07:16,410
Now, I will enter the correct credentials which are in the database here.

84
00:07:16,430 --> 00:07:17,630
I'm saying happy.

85
00:07:18,110 --> 00:07:19,540
One, two, three, four, five.

86
00:07:19,590 --> 00:07:20,480
As a credential.

87
00:07:20,750 --> 00:07:29,270
Not sitting on this will stop my breakpoint because now this query resulting some rows.

88
00:07:29,520 --> 00:07:33,080
That's the reason we stopped at this point.

89
00:07:33,230 --> 00:07:40,460
And you can see here, this will be called by the hour Davo authentication provider Retriever's.

90
00:07:40,970 --> 00:07:42,860
So here it will go.

91
00:07:42,860 --> 00:07:46,970
And look, what is the implementation of user detail service?

92
00:07:47,840 --> 00:07:56,890
And we said that go ahead and use JBC user details manager by creating a bit of user detail service.

93
00:07:57,230 --> 00:08:05,810
So that's the reason are the authentication provider will call the Jadick user details manager Materne

94
00:08:06,110 --> 00:08:07,940
and will try to authenticate.

95
00:08:08,210 --> 00:08:12,080
So now in this scenario is that authentication is successful.

96
00:08:12,440 --> 00:08:17,510
We are showing the response provided by the my account service with this.

97
00:08:17,630 --> 00:08:21,020
I'm assuming it is making sense to you guys.

98
00:08:21,020 --> 00:08:28,940
If we have any questions, please post in Q&A section and in the next video, let's try to how to customize

99
00:08:28,940 --> 00:08:33,289
this database, see user details, manager asport requirements.

100
00:08:33,380 --> 00:08:35,720
Like I want to have my own table.

101
00:08:35,840 --> 00:08:40,610
I want to have my own aluminum's as per my position requirement.

102
00:08:40,610 --> 00:08:47,090
I don't want to go with what our naming conventions that is provided by JBC User Details Manager.

103
00:08:47,270 --> 00:08:48,800
So all such requirements.

104
00:08:49,040 --> 00:08:50,790
We will look in the next room.

105
00:08:50,900 --> 00:08:51,530
Thank you.

106
00:08:51,530 --> 00:08:51,860
By.

