Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hardiksinghbehl/otp-generation-validation-spring-boot-poc
Proof Of Concept showing OTP generation and validation technique using Java Spring-boot and LoadingCache Bean from google guava library to handle user's forgot-password flow
https://github.com/hardiksinghbehl/otp-generation-validation-spring-boot-poc
guava-cache java otp-generator otp-verification spring-boot
Last synced: about 1 month ago
JSON representation
Proof Of Concept showing OTP generation and validation technique using Java Spring-boot and LoadingCache Bean from google guava library to handle user's forgot-password flow
- Host: GitHub
- URL: https://github.com/hardiksinghbehl/otp-generation-validation-spring-boot-poc
- Owner: hardikSinghBehl
- Created: 2021-06-06T16:55:23.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-06-06T21:34:42.000Z (over 3 years ago)
- Last Synced: 2024-05-10T18:57:45.209Z (8 months ago)
- Topics: guava-cache, java, otp-generator, otp-verification, spring-boot
- Language: Java
- Homepage: https://spring-boot-otp-validator.herokuapp.com/swagger-ui.html
- Size: 76.2 KB
- Stars: 14
- Watchers: 2
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# OTP Generation And Validation Using Spring Boot
#### Proof Of Concept showing OTP generation and validation technique using Java Spring-boot and LoadingCache Bean from google guava library to handle user's forgot-password flow[Running Application](https://spring-boot-otp-validator.herokuapp.com/swagger-ui.html)
---```
@Bean
public LoadingCache loadingCache() {
return CacheBuilder.newBuilder().expireAfterWrite(5, TimeUnit.MINUTES)
.build(new CacheLoader<>() {
public Integer load(UUID key) {
return 0;
}
});
}
```
The Above bean is used to store the generated OTP corresponding to the user's unique id (UUID)The expiration minute(s) for OTP can be set in the application.properties file after which the OTP will be automatically removed from the cache
```
com.hardik.hadraniel.otp.expiration-minutes=5
```In a real implementation, the generated OTP will be sent to the user's entered email-id/phone number rather than a response to an API
All the logic can be found at UserService.class
---
## Local Setup* Install Java 15
* Install MavenRecommended way is to use [sdkman](https://sdkman.io/) for installing both maven and java
Run the below commands in the core
```
mvn clean install
``````
mvn spring-boot:run
```Run the below command to run Tests
```
mvn test
```server port is configured to 8090 and expiration minute(s) for OTP is configured to 5 minutes (can be changed in application.properties file)
Go to the below url to view swagger-ui (API docs)
```
http://localhost:8090/swagger-ui.html
```