A production-ready authentication and authorization service built with Spring Boot, designed for SaaS applications requiring secure multi-tenant authentication.
The service supports local authentication, OAuth2 login, JWT authentication, refresh token rotation, role-based access control, email verification, password reset, and tenant-aware authorization.
Live API:- mtAuth Swagger
- Multi-Tenant Authentication
- JWT Access & Refresh Tokens
- Refresh Token Rotation
- Redis-backed Token Management
- JWT Blacklisting using Redis Pub/Sub
- OAuth2 Login (Google, GitHub, etc.)
- Email Verification
- Password Reset
- Role-Based Access Control (RBAC)
- Client Registration
- Tenant Isolation
- Stateless Authentication
- Local Signup Email Verification
| Technology | Version |
|---|---|
| Java | 17 |
| Spring Boot | 4.0.7 |
| Spring Security | 7 |
| PostgreSQL | Local (Development) |
| Neon PostgreSQL | Production |
| Redis | Local (Development) |
| Redis Cloud | Production |
| Maven | 3.9.x |
| OAuth2 | Authorization Code Flow |
| JWT | Access & Refresh Tokens |
+----------------+
| Frontend |
+-------+--------+
|
|
JWT / OAuth Requests
|
▼
+----------------------------+
| Multi-Tenant Auth Service |
+----------------------------+
| |
| |
▼ ▼
PostgreSQL Redis
(Users, Roles, Refresh Tokens,
Clients...) Blacklist, OAuth
- JWT Authentication
- Refresh Token Rotation
- Redis-backed Refresh Tokens
- JWT Blacklisting
- Redis Pub/Sub Synchronization
- OAuth Authorization Code Exchange
- Email Verification
- Password Reset Tokens
- Client Secret Validation
- Tenant Isolation
- Role-Based Authorization
Signup
↓
Verify Email
↓
Login
↓
Access Token + Refresh Token
↓
Refresh Token Rotation
↓
Logout
Frontend
↓
/oauth/{provider}/start
↓
OAuth Provider
↓
/oauth/{provider}/callback
↓
Temporary Exchange Code
↓
/oauth/exchange
↓
Access Token + Refresh Token
- Java 17
- Maven
- PostgreSQL
- Redis
git clone https://github.com/harsh25519/mtAuth.git
cd <repository where you clone repo>Create an application-dev.properties (or use environment variables) and configure:
- PostgreSQL
- Redis
- SMTP Mail
- JWT Secret
- OAuth Client Credentials
./mvnw spring-boot:runor
mvn spring-boot:runThe application starts on
http://localhost:8080
Once the application is running:
http://localhost:8080/swagger-ui.html
Detailed documentation is available in the docs folder.
- Authentication APIs
- OAuth APIs
- User APIs
- Client APIs
- Security
- Error Responses
docs/
├── authentication.md
├── oauth.md
├── users.md
├── clients.md
├── security.md
└── getting-started.md
| Role | Description |
|---|---|
| AUTH_ADMIN | Global administrator |
| ADMIN | Tenant administrator |
| USER | Standard authenticated user |
| Token | Lifetime |
|---|---|
| Access Token | 15 Minutes |
| Refresh Token | 7 Days |
| OAuth Exchange Code | 30–60 Seconds |
| Service | Development | Production |
|---|---|---|
| PostgreSQL | Local PostgreSQL | Neon PostgreSQL |
| Redis | Local Redis | Redis Cloud |
This project is licensed under the MIT License.