A secure, extensible authentication and authorization backend for modern applications built with Spring Boot. Designed for scalability and real-world integration, this project includes JWT, OAuth2, role-based access, admin controls, and token lifecycle management.
- User Registration & Login (JWT-based)
- Refresh Token handling (per user, revocable)
- GitHub OAuth2 login support
- Role-based Access Control (User/Admin)
- Audit Logging (for all sensitive actions)
- Admin Delegation (promote/demote users)
- Token Revocation on logout
- Account Lock/Unlock Management
- Java 21
- Spring Boot 3
- Spring Security
- JWT (Access & Refresh)
- OAuth2 (GitHub)
- MySQL
- Hibernate (JPA)
- Lombok
- MapStruct (optional)
- Docker (optional for deployment)
| Method | Endpoint | Description |
|---|---|---|
| POST | /auth/register |
Register a new user |
| POST | /auth/login |
Login with email & password |
| POST | /auth/oauth |
GitHub OAuth login |
| POST | /auth/reset-request |
Request password reset token |
| POST | /auth/reset-password |
Reset password using token |
| POST | /auth/refresh |
Revoke refresh token |
| Method | Endpoint | Description |
|---|---|---|
| GET | /auth/me |
Get logged-in user profile |
| PUT | /auth/update |
Update profile |
| POST | /auth/logout |
Logout |
| Method | Endpoint | Description |
|---|---|---|
| GET | /admin/users |
View all users |
| PUT | /admin/users/{id}/roles |
Update user roles to relevent user |
| GET | /admin/audit-logs |
View audit logs |
| GET | /admin/roles |
List all available roles |
| POST | /admin/delegate |
Delegate admin role to another user |
| POST | /admin/users/roles |
Update user roles |
Authzen/
├── src/
│ ├── main/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── yourorg/
│ │ │ └── authzen/
│ │ │ ├── AuthzenApplication.java
│ │ │ ├── configs/
│ │ │ ├── constants/
│ │ │ ├── controllers/
│ │ │ ├── dtos/
│ │ │ ├── endpoints/
│ │ │ ├── exceptions/
│ │ │ ├── models/
│ │ │ ├── repositories/
│ │ │ ├── responses/
│ │ │ ├── security/
│ │ │ ├── services/
│ │ │ └── utils/
│ │ └── resources/
│ │ ├── application.yml
│ │ ├── static/
│ │ │ ├── css/
│ │ │ ├── js/
│ │ │ └── reset-password/
│ │ └── templates/
├── .env
├── .env.docker
├── .env.example
├── .gitignore
├── docker-compose.yml
├── Dockerfile
├── HELP.md
├── LICENSE.md
├── mvnw
├── mvnw.cmd
├── pom.xml
└── README.md
git clone https://github.com/kgchinthana/authzen.git
cd authzenCreate .env file in root directory:
SPRING_APPLICATION_NAME=authzen
SPRING_DATASOURCE_URL=jdbc:mysql://localhost:3306/authzen?createDatabaseIfNotExist=true
SPRING_DATASOURCE_USERNAME=root
SPRING_DATASOURCE_PASSWORD=yourpassword
SERVER_PORT=8080
JWT_SECRET=your_secret_key
JWT_ACCESS_TOKEN_EXPIRY_MS=900000
JWT_REFRESH_TOKEN_EXPIRY_MS=604800000
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=youremail@gmail.com
MAIL_PASSWORD=yourapppassword
EMAIL_FROM=noreply@yourdomain.com
GITHUB_CLIENT_ID=your_client_id
GITHUB_CLIENT_SECRET=your_client_secret
GITHUB_REDIRECT_URI=http://localhost:8080/oauth/callback
ADMIN_EMAIL=admin@yourdomain.com
ADMIN_USERNAME=admin
ADMIN_PASSWORD=Admin@123Register a GitHub OAuth App:
- Homepage:
http://localhost:8080 - Callback:
http://localhost:8080/auth/oauth
Set in .env:
GITHUB_CLIENT_ID=your_client_id
GITHUB_CLIENT_SECRET=your_client_secret
GITHUB_REDIRECT_URI=http://localhost:8080/oauth/callback./mvnw spring-boot:runRoles (ROLE_USER, ROLE_ADMIN) will be auto-initialized.
- Frontend gets GitHub access token from GitHub
- Sends it to
/auth/oauth - Server verifies token with GitHub & links to user
POST /auth/register
Content-Type: application/json
{
"username": "alice",
"email": "alice@example.com",
"password": "securepass"
}| Key | Description |
|---|---|
GITHUB_CLIENT_ID |
GitHub OAuth client ID |
GITHUB_CLIENT_SECRET |
GitHub OAuth client secret |
JWT_SECRET |
JWT signing key |
JWT_EXPIRATION |
Access token duration |
REFRESH_TOKEN_EXPIRATION |
Refresh token duration |
users: user credentials and metadataroles: available rolesuser_roles: user-role associationsrefresh_tokens: long-lived refresh tokensoauth_providers: linked GitHub accountsaudit_logs: admin actions trackingemail_tokens: password reset tokenspermissions: defines fine-grained permissionsrole_permissions: role-permissions associations
- BCrypt hashed passwords
- JWT with separate refresh token DB
- Role-checking via
@PreAuthorize&SecurityContext - Admin-only endpoints protected with
ROLE_ADMIN - GitHub token verification before linking
- Fork the repo
- Fix a bug or implement a feature
- Submit a pull request
For the open-source competition, check the issues tab for bugs to solve!
MIT © 2025 — CodeJam Codex Team
