Basic authentication with spring boot (bare minimum)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
okay in this video I am going to show you a springboard basic authentication demo uh so let's get started so this is a bare minimum uh springboard project has no dependency for security so let's add that so over here I'm adding um security and web dependencies so I am going to secure the rest apis so that's why I need the web included so that's done so first we need to build in order to get all the necessary uh dependency dependencies so once it's done okay now we will start adding uh other things so let's um start by adding a rest controller so I'll just add it in the same package I don't want toate created a separate package at the moment because this is just a demo okay so as you can see there is two apis over here uh one is restricted one is permitted so I wanted to uh only authenticated people to access this one and this one will be uh open for public so anybody can access this without any authentications so I have created the rest controller now the next thing I need is the configurations uh Spring Security configurations so let's create the class here same level as the other classes okay uh over here I have disabl the C csrf at the moment uh I'm not going to go into detail on how to do it properly so I'm just disabling it now uh and this this ation will be a HTTP basic authentication um so I have I set this uh API to be authenticated and this API to be permit all so uh let's uh uh let's uh test this actually yeah we build this ones okay and then we run this okay as you can see the password is given over here we'll copy this password first all right so so this is the uh client I'm using at the moment to test the rest API so the permitted URL is here so let's test okay it is uh there is no authentication Ed given and it successfully uh get the data from the back end okay this is fine let's try this so there is no authentication given so let's see now it's giving 41 so unauthorized okay that's uh correct correct so let's uh add an uh authentication so the default username is user the password is as we copy it earlier okay now let's see okay now it works uh uh I I don't like the default um usern and password generated by springboard so I usually will set the default username and password in the uh application. properties so this will be my username and password okay I'll stop and run it again with this new changes so first of all we'll try running it again check if it still authenticates okay this is correct so what I need to do is I need to change this but instead of us uh adding a authorization I will use this one the generator to generate the the base 64 encoded username and password so basically you have to give the username and password and then this will give us give the base 64 encoded username and password so I'll just copy this go here and then paste it here and then now let's see okay now it's authenticate that is uh expected so so that's about it uh this is the B minimum of uh uh base authentication and spring Bo okay
Info
Channel: greenhorn
Views: 580
Rating: undefined out of 5
Keywords:
Id: rE5i03c2VVY
Channel Id: undefined
Length: 5min 40sec (340 seconds)
Published: Wed Nov 22 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.