Spring Boot project with demonstration of OTP authentication technique.
- Create database with name otp
- Open terminal and navigate to your project
- Type command mvn install
- Type command mvn spring-boot:run
Route: http://localhost:8080/
- Development profile (dev)
- Production profile (prod)
Route: /auth/authenticate
Method: POST
Content-Type: application/json
Request payload: { username: "admin", password: "admin" }
Response: { id_token: "token_hash" }
-
Generate OTP and send it to e-mail
Route: /api/otp/generate
Method: POST
Empty request body in this case. -
Validate OTP
Route: /api/otp/validate
Method: POST
Example Request Payload: { "otp": "your otp number" }
- mvn clean
- mvn -Pprod package
15.07.2022.
- Removed OTPResourceController. All Otp logic is processed in AuthenticationController
- Added new column in user table -> is_otp_required
- Modified TokenProvided to support logic that first check if otp is required. If OTP is not needed token will be generated instantly, but if OTP is required token will not be provided to end user (client), email will be sent with OTP code
- OTP can be verified used /auth/verify route in AuthenticationController
Heril Muratović
Software Engineer
Mobile: +38269657962
E-mail: [email protected]
Skype: hedza06
Twitter: hedzakirk
LinkedIn: https://www.linkedin.com/in/heril-muratovi%C4%87-021097132/
StackOverflow: https://stackoverflow.com/users/4078505/heril-muratovic