Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/sandeepkv93/user-management-springboot


https://github.com/sandeepkv93/user-management-springboot

Last synced: about 2 months ago
JSON representation

Awesome Lists containing this project

README

        

[![Build Status](https://github.com/sandeepkv93/user-management-springboot/actions/workflows/ci.yml/badge.svg)](https://github.com/sandeepkv93/user-management-springboot/actions/workflows/ci.yml)
[![codecov](https://codecov.io/gh/sandeepkv93/user-management-springboot/branch/main/graph/badge.svg?token=CODECOV_TOKEN_HERE)](https://codecov.io/gh/sandeepkv93/user-management-springboot)

# ๐Ÿ” User Management Service

A powerful Spring Boot application for managing users with OAuth2 social login and AWS S3 integration! ๐Ÿš€

## โœจ Features

### ๐ŸŽฏ Core Features
- ๐Ÿ”‘ JWT Authentication & Authorization
- ๐ŸŒ OAuth2 Social Login (Google & GitHub)
- ๐Ÿ‘ค User Profile Management
- ๐Ÿ–ผ๏ธ Profile Picture Storage (AWS S3)
- ๐Ÿ“Š Role-Based Access Control
- ๐Ÿ”„ Token Refresh Mechanism

### ๐Ÿ› ๏ธ Technical Stack
- โ˜• Java 21
- ๐Ÿƒ Spring Boot 3.2
- ๐Ÿ˜ PostgreSQL 16
- ๐Ÿณ Docker & Docker Compose
- ๐Ÿ“ฆ LocalStack (S3 Emulation)
- โœˆ๏ธ Flyway Migrations

## ๐Ÿ—๏ธ Architecture

```mermaid
flowchart TB
Client[Client Applications]
Auth[Authentication Service]
User[User Service]
S3[S3 Service]
DB[(PostgreSQL)]
S3Store[(S3 Storage)]

Client -->|Authentication Requests| Auth
Client -->|User Management| User
Auth -->|User Data| DB
User -->|Profile Data| DB
User -->|Profile Pictures| S3
S3 -->|Store/Retrieve| S3Store

style Client fill:#f9f,stroke:#333,stroke-width:4px
style Auth fill:#bbf,stroke:#333,stroke-width:2px
style User fill:#bbf,stroke:#333,stroke-width:2px
style S3 fill:#bbf,stroke:#333,stroke-width:2px
style DB fill:#bfb,stroke:#333,stroke-width:2px
style S3Store fill:#bfb,stroke:#333,stroke-width:2px
```

### ๐Ÿ”„ Authentication Flow

```mermaid
sequenceDiagram
actor User
participant Client
participant Auth
participant DB

User->>Client: Login Request
Client->>Auth: Authenticate
Auth->>DB: Validate Credentials
DB-->>Auth: User Data
Auth-->>Client: JWT + Refresh Token
Client-->>User: Login Success

Note over User,DB: Token Refresh Flow
Client->>Auth: Refresh Token
Auth->>DB: Validate Refresh Token
DB-->>Auth: Token Valid
Auth-->>Client: New JWT
```

## ๐Ÿš€ Getting Started

### ๐Ÿ“‹ Prerequisites
- โ˜• Java 21
- ๐Ÿ“ฆ Maven
- ๐Ÿณ Docker & Docker Compose
- ๐Ÿ˜ PostgreSQL 16
- ๐Ÿ’ป Your favorite IDE!

### ๐Ÿ”ง Setup

1. **๐Ÿ“ฅ Clone the Repository**
```bash
git clone
cd user-management
```

2. **๐Ÿณ Start Infrastructure**
```bash
docker-compose up -d
```

3. **๐ŸŽฏ Initialize S3**
```bash
chmod +x scripts/init-localstack.sh
./scripts/init-localstack.sh
```

4. **โš™๏ธ Configure Application**

Create `application.yml` with your settings:
```yaml
spring:
datasource:
url: jdbc:postgresql://localhost:5432/user_management
username: user
password: password

app:
jwt:
secret: ${JWT_SECRET:your-secret-key}
aws:
s3:
bucket-name: user-profiles
```

5. **๐Ÿš€ Build & Run**
```bash
mvn clean install
mvn spring-boot:run
```

## ๐Ÿ”Œ API Reference

### ๐Ÿ” Authentication

#### ๐Ÿ“ Register
```http
POST /api/auth/signup
{
"username": "cooluser123",
"email": "[email protected]",
"password": "secure123!"
}
```

#### ๐Ÿ”‘ Login
```http
POST /api/auth/login
{
"email": "[email protected]",
"password": "secure123!"
}
```

### ๐Ÿ‘ค User Management

#### ๐Ÿ“ฑ Get Profile
```http
GET /api/users/me
Authorization: Bearer
```

#### ๐Ÿ–ผ๏ธ Update Profile Picture
```http
POST /api/users/me/profile-picture
Authorization: Bearer
Content-Type: multipart/form-data
```

### ๐ŸŒ OAuth2 Login

#### ๐Ÿ”ท Google
```http
GET /oauth2/authorization/google
```

#### ๐Ÿฑ GitHub
```http
GET /oauth2/authorization/github
```

## ๐Ÿ”’ Security Features

### ๐Ÿ” Authentication
- ๐ŸŽŸ๏ธ JWT Tokens (1 hour validity)
- ๐Ÿ”„ Refresh Tokens (30 days validity)
- ๐Ÿ”’ BCrypt Password Encryption

### ๐Ÿ‘ฎ Authorization
- ๐Ÿ‘ฅ Role-Based Access Control
- ๐Ÿ›ก๏ธ Method-Level Security
- ๐Ÿšซ CORS Protection

## ๐Ÿงช Testing

```bash
# ๐Ÿงช Run all tests
mvn test

# ๐Ÿ“Š Generate coverage report
mvn verify
```

## ๐Ÿ”ง Development

### ๐Ÿ“ Code Style
```bash
# ๐ŸŽจ Format code
mvn com.spotify.fmt:fmt-maven-plugin:format
```

### ๐Ÿ“š Database Migrations
```bash
# ๐Ÿ”„ Run migrations manually
mvn flyway:migrate
```