This repo provides the code base for a Java Spring boot app with easy to understand code samples of how to implement basic authentication in a Java Spring boot application using Spring Security 6.
- Java 17
- Spring Boot 3.2.1
- Spring Security 6 and above
- Lombok 1.18.30
Clone the repo, go into the directory and run with M
git clone git@github.com:cptdanko/custom-spring-auth.git
cd custom-spring-boot-basic-auth
mvn spring-boot:run
Once the spring-boot application is running, one of the ways you can test it is using Postman
- Launch Postman
- Import the Postman collection from the PostmanCollection folder of the repo
- Test the 3 API endpoints, of which
- Say Hello and Create User are the endpoints protected with basic auth
- Ping user is not secure and can be called without any credentials
To do so, change the username and password on line 47 of the SecurityConfig class in this repo.
If you have difficulty understanding anything about this repo, feel free to reach out to me through this Github account or at bhuman@mydaytodo.com or bhuman.soni@gmail.com
I will be writing a detailed tutorial on how to work with this repo on my blog. Until then refer to my blog for other tutorials and "how-to" articles with detailed code samples.
If you like what I am doing, you can buy me a coffee