r/SpringBoot • u/Disastrous-Name-4913 • Jul 17 '25
How-To/Tutorial Spring Boot Authentication, step by step
Hi! I've struggled with the Spring Security topic myself, and that'as why I decided to write a small article about how to simply secure a website with a username and password. It is divided in the following sections:
Create a non-secured web
Introduce Authentication
Activate default Spring Security
Define a custom hardcoded user/plain password in the configuration
Encode the password
Specify the encoder
Use a custom User Details Service that contains the hardcoded user/password
Retrieve the user/password from an in-memory database (H2)
Retrieve the user/password from an on-disk database (MySQL)
I felt like every article or official documentation introduced too much stuff, like authorization, roles etc. which I understand are important too, but it felt like trying to learn what a variable is and having to deal with streams directly.
I'll be happy to get any feedback.
1
u/Rough-Historian-2614 Jul 17 '25
Great work. Easy to explain flow how it's done.