https://github.com/aprendendo-programacao/totp-authentication
Simple Spring Boot application demonstrating 2FA authentication using TOTP (Time-based One-Time Password), compatible with Google Authenticator, Authy, and similar apps.
https://github.com/aprendendo-programacao/totp-authentication
2fa-security java spring totp
Last synced: about 2 months ago
JSON representation
Simple Spring Boot application demonstrating 2FA authentication using TOTP (Time-based One-Time Password), compatible with Google Authenticator, Authy, and similar apps.
- Host: GitHub
- URL: https://github.com/aprendendo-programacao/totp-authentication
- Owner: Aprendendo-programacao
- Created: 2025-05-31T22:30:05.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-05-31T22:34:35.000Z (about 1 year ago)
- Last Synced: 2025-06-29T11:04:26.192Z (12 months ago)
- Topics: 2fa-security, java, spring, totp
- Language: Java
- Homepage:
- Size: 14.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# TOTP Authentication Demo
This project is a simple Spring Boot application demonstrating 2FA authentication using TOTP (Time-based One-Time Password), compatible with Google Authenticator, Authy, and similar apps.
## Features
- User registration and login
- Enable/disable TOTP 2FA per user
- TOTP QR code generation for easy setup in authenticator apps
- PostgreSQL database integration
## Prerequisites
- Java 17+
- Maven
- Docker & Docker Compose
## Getting Started
### 1. Clone the repository
```
git clone git@github.com:Aprendendo-programacao/totp-authentication.git
cd totp-authentication
```
### 2. Start PostgreSQL with Docker Compose
```
docker-compose up -d
```
This will start a PostgreSQL 17.4 instance with the following credentials:
- Database: `totp_auth_db`
- User: `totp_user`
- Password: `totp_pass_123`
### 3. Build and run the application
```
./mvnw spring-boot:run
```
The application will start on [http://localhost:8080](http://localhost:8080).
## Usage
1. Register a new user at `/register`.
2. Login at `/login`.
3. After login, you will be prompted to enable TOTP 2FA:
- Scan the QR code with your authenticator app (Google Authenticator, Authy, etc).
- Enter the 6-digit code from your app to activate 2FA.
4. On subsequent logins, you will be required to enter the TOTP code.
## Notes
- Passwords are stored in plain text for demo purposes. **Do not use in production!**
- TOTP validation is implemented according to RFC 6238.
- The UI is intentionally minimal for demonstration and testing.
## Stopping the Database
To stop the PostgreSQL container:
```
docker-compose down
```