In the previous video, we have all rated the configurator method available in Bring Security to customize
and provide user details ASPO requirement.
And at the same time we also configure multiple users with the name admin user along with their authorities.
Now, with this configuration, we don't need these credentials mentioned in the application or properties
because they are absolutely no reason to bring security.
Always consider these users as a first priority.
If we don't customize this method, then it will go and look for the credentials in the application
or properties.
I want to show you either way on how we can provide and customize user detail to spring security in
this video to further.
First, let's amend the method that we have written previously and now we have the same method already,
but in a different manner.
Previously we used in-memory authentication.
Now, instead of that, I am trying to use a in-memory user details manager, which by default provided
by the spring security vendor.
We want to store the user details inside memory of our application.
So in this scenario, memory user details manager is an implementation of user details, which I will
use inside this method once we ensure that we have to build the users that we want to build for our
application.
If we see previously I was saying we have user user details and user details, services, all such interfaces,
classes available inside our security will be discussing about all this in detail in the coming videos.
But for now you can understand that using user we call with user name method where we pass the user
name, password and authority details and calling build on this code will give the user details associated
with this user.
Similarly, we are building another user called user one with a detailed user password and authorities
as what the users we have to pass to the user details service by calling create user.
So since I have declared to users here, I have to pass both of them to create user two times post that
I have to set this user detail service, which is of in-memory user details manager inside my user detail,
service of authentication manager build.
With this it will be work similarly like we have seen in the previous video.
But the only thing right now here missing is password encoder.
Let's try to see what will happen if we don't have any password encoder whenever we try to customize
users as per the requirement.
So I'm saving this configuration, going to bring good starter class, putting this over the server
stats perfectly.
Now I'm clearing the console to see whatever that we get calling my account.
And since it's a security redirect login page and asking my undervalued currency, I mean, one, two,
three, four, five, you can see that we have an error thrown and the details of error.
Each is no password and kodet mapped.
That means spring security framework.
All of us will expect a password and to be mapped are custom user details.
We have configured result this error.
Let's start this over and go to a configuration class here.
We have to create a bit of time password encoder and I am returning no password encoder as the type
for this being here.
My spring security sends it to find a bit of my password quarter.
It takes this as a default password encoder that it has to assume for this user details custom configurations
that we have done here with error.
We should have solved that exception.
Let's try to start our application again to my account.
It's time entering admin one, two, three, four file and we've gotten spun successfully.
That's one leanly.
We can see the same response using the other credentials user that we have defined.
Let's see that one also.
Oh, entering the details of user followed by his password.
It is one, two, three, four.
Now, at question is we also learned another way of defining our users and letting the default implementation
of user detail service along with the password and Encoder Bassingthwaighte.
So we have seen total two ways.
One is by using the in-memory authentication, which is of like some people may feel like, I'm not
able to understand what is happening here, but if we want to have some clear code, I would always
recommend you to use in-memory user details manager where we first defined the users and pass them to
user details service, which will be used eventually to authenticate unmanageability.
We also have been created by password in order for this custom user details implementation that we have
done here in this class.
Thank you.
And see you in the next week by.