Skip to content

This Spring Boot application with Spring Security features a role-based (User/Admin) registration and login system using JWT for authentication. It employs Caffeine cache for OTP storage, and a retry mechanism for email OTP delivery. Further access is restricted to verified users with valid tokens.

Notifications You must be signed in to change notification settings

Sarthakverse/Jwt-Authentication-Authorization-for-SpringBoot-3.3.0

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LoginSignupLogo

Registration and Login

  • This backend application, developed using Spring Boot 3.3.0 and Spring Security 6.X.X.
  • implements a role-based (User/Admin) registration and login system.
  • It leverages Caffeine cache for storing OTPs sent via email for verification purposes.
  • Upon successful registration, the application generates JWT tokens: an access token (valid for 1 hour) and a refresh token (valid for 30 days).
  • These tokens are used to authorize users, ensuring that only verified users with valid tokens can access certain endpoints outside of the "/api/v1/auth/**" path.
  • To enhance reliability, a retry mechanism is implemented for email sending, which attempts to resend the OTP up to two more times in case of a system failure.
  • Additionally, the application includes robust validation checks, ensuring that request bodies meet the required criteria.

Demo and Documentation

Built With

  • Springboot
  • JWT
  • CaffeineCache
  • Swagger
  • Spring Security
  • Java Mail Sender
  • Cron Job

Hosted Url

To use the REST_APIs use this url

  https://jwt-authentication-authorization-for.onrender.com/

Importatant Depenedencies used in project

  • spring-boot-starter-web
  • spring-boot-starter-data-jpa
  • spring-boot-starter-mail
  • spring-boot-starter-security
  • spring-boot-starter-validation
  • springdoc-openapi-starter-webmvc-ui
  • postgresql
  • lombok
  • spring-retry
  • jjwt
  • jjwt-impl
  • jjwt-api
  • spring-boot-starter-cache
  • caffeine

Project Roadmap

1. Set Up the Environment

  • Install JDK 17
  • Install an IDE
    • Download and install IntelliJ IDEA or Eclipse
    • Configure IDE for Java 17
    • Install necessary plugins for Spring Boot development

Clone the repo

git clone https://github.com/Sarthakverse/Jwt-Authentication-Authorization-for-SpringBoot-3.3.1.git

Open the cloned folder using STS, IntelliJ Idea or any other IDE, and it will auto download all the configuration files.

Run the project, the base URL for the project will be

http://localhost:8080/

Get the documentation for the various APIs at the following link

http://localhost:8080/swagger-ui/index.html

Get the postman collection at the following link

https://crimson-flare-571775.postman.co/workspace/Green-Stitch~dcfa712e-5f25-40e2-aedf-60b0e52bcca6/collection/24017701-6dfd191f-0f0c-46c0-a63c-d71dde765b9e?action=share&creator=24017701

Some ScreenShots

image image image image image

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Contact Information

About

This Spring Boot application with Spring Security features a role-based (User/Admin) registration and login system using JWT for authentication. It employs Caffeine cache for OTP storage, and a retry mechanism for email OTP delivery. Further access is restricted to verified users with valid tokens.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published