JWT authentication and authorization implementation in a Spring Boot 3.2.3 application using Spring Security and PostgreSQL database to store user credentials.
Implementation is based on Amigoscode and Bouali Ali YouTube tutorial Spring Boot 3 + Spring Security 6 - JWT Authentication and Authorisation but using Java 21, Spring Boot 3.2.3, and newer version of JJWT library.
Find more about Bouali Ali at his YouTube channel
- User registration and authentication with JWT
- Demo authenticated endpoint
- Password encryption with BCrypt
- Role-based authorization with Spring Security
- Java 21
- Spring Boot 3.2.3
- Spring Security 6.2.2
- JSON Web Token (JWT) with jjwt library
- BCrypt
- Spring Data JPA
- PostgreSQL
- Lombok
- Maven
- Java 21
- Maven 3+
- PostgreSQL
- Clone the repository.
- Create a PostgreSQL database named
jwt_security. - Update the
application.ymlfile with your database credentials. - Build the project using Maven:
mvn clean install- Run the project:
mvn spring-boot:run- The application will be running at
http://localhost:8080.
Find the .http file in the http directory and use it to test the API.
Import the Postman collection from the http directory.