- Java Jwt Example, the project leverages modern technologies such as Java, Javalin, and MongoDB, implementing JWT-based authentication and advanced security features like account verification and password reset via email.
- Implements JWT-based authentication and authorization.
- Implements request validation and middleware.
- Account verification.
- Password reset.
- Organized and understandable app structure.
- Backend: Java, Javalin, java-jwt, commons-email
- Database: MongoDB
- Architecture: RESTful JSON API
- Java 17: This project requires Java version 17 or higher.
- Maven: You need to have Maven installed to build and run the project.
- MongoDB: You need to have a running MongoDB instance to connect to.
| Method | Endpoint | Description | Parameters |
|---|---|---|---|
| POST | /api/auth/sign-up | Send email to verify account | email: string, password: string, confirmPassword: string |
| POST | /api/auth/sign-in | Returns JWT token | email: string, password: string |
| POST | /api/auth/reset-password/{email} | Send email to reset password | email: string |
| Method | Endpoint | Description | Parameters |
|---|---|---|---|
| GET | /api/users/{userId} | Returns a specific user for the authenticated user. | userId: string |
| DELETE | /api/users/{userId} | Delete a specific user for the authenticated user. | userId: string |
- Clone this repository to your local machine:
git clone https://github.com/Isacco-B/java-jwt-example.gitRename the ./src/main/resources/.env.example file to ./src/main/resources/.env and update the values.
MODE=development | production
JWT_SECRET=1234
SERVER_PORT=7000
SERVER_URL=http://localhost
DB_HOST=mongodb://localhost:27017
DB_NAME=notes_app
EMAIL_ADDRESS=
EMAIL_HOST=
EMAIL_PASSWORD=
EMAIL_PORT=If you set MODE=development, you don't need to specify EMAIL settings. The verification end reset link will be printed on the console.
- Create and run the jar file:
mvn clean packagecd targetjava -jar java-jwt-example.jar