Initial commit: OAuth 2.0 인증 시스템 with APISIX API Gateway

- FastAPI 백엔드 + MongoDB + Redis 구성
- React + Vite + TypeScript + shadcn/ui 프론트엔드
- Apache APISIX API Gateway 통합
- Docker Compose 기반 개발 환경
- 3단계 권한 체계 (System Admin, Group Admin, User)
- 동적 테마 지원
- 환경별 설정 (dev/vei/prod)

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Claude
2025-08-31 10:16:41 +09:00
commit f53d55e712
55 changed files with 6798 additions and 0 deletions

209
oauth/docs/architecture.md Normal file
View File

@ -0,0 +1,209 @@
# OAuth 시스템 아키텍처
## 시스템 구성도
```mermaid
graph TB
subgraph "Client Layer"
Browser[사용자 브라우저]
end
subgraph "API Gateway Layer"
APISIX[Apache APISIX<br/>- API Gateway<br/>- Rate Limiting<br/>- Authentication<br/>- Load Balancing]
etcd[etcd<br/>- Service Discovery<br/>- Configuration Store]
end
subgraph "Application Layer"
Backend[FastAPI Backend<br/>- Auth Logic<br/>- JWT Handling<br/>- Business Logic]
Frontend[React Frontend<br/>- Dynamic UI<br/>- Theme Engine<br/>- SPA Routing]
end
subgraph "Data Layer"
MongoDB[MongoDB<br/>- Users<br/>- Apps<br/>- History]
Redis[Redis<br/>- Cache<br/>- Queue<br/>- Session]
Celery[Celery<br/>- Tasks<br/>- Jobs]
Backup[Backup Service<br/>- Cron Jobs<br/>- Archives]
end
Browser -->|HTTP/HTTPS| APISIX
APISIX -->|/api/v1/*| Backend
APISIX -->|/*| Frontend
APISIX <--> etcd
Backend --> MongoDB
Backend --> Redis
Backend --> Celery
Backend --> Backup
```
## 데이터 플로우
### 1. 인증 플로우
```mermaid
sequenceDiagram
participant User as 사용자
participant App as 애플리케이션
participant OAuth as OAuth 서버
participant DB as Database
User->>App: 1. 접속
App->>OAuth: 2. 리다이렉트 (client_id, redirect_uri)
OAuth->>User: 3. 동적 로그인 페이지 렌더링
User->>OAuth: 4. 인증 정보 입력
OAuth->>DB: 5. 인증 검증
OAuth->>User: 6. Authorization Code 발급
User->>App: 7. Code 전달
App->>OAuth: 8. Access Token 요청
OAuth->>App: 9. Access Token 발급
App->>OAuth: 10. 사용자 정보 요청
OAuth->>App: 11. 권한별 사용자 정보 제공
```
### 2. 토큰 관리
- Access Token: 30분 유효
- Refresh Token: 7일 유효
- Token Rotation 정책 적용
## 마이크로서비스 구조
```mermaid
graph LR
subgraph "Core Services"
Auth[Authentication Service]
Authz[Authorization Service]
UserMgmt[User Management Service]
AppService[Application Service]
Audit[Audit Service]
end
subgraph "Support Services"
Cache[Cache Service]
Queue[Queue Service]
Backup[Backup Service]
end
Auth --> Cache
Auth --> Queue
Authz --> Cache
UserMgmt --> Audit
AppService --> Audit
```
### Core Services
1. **Authentication Service**
- 사용자 인증
- 토큰 발급/검증
- 세션 관리
2. **Authorization Service**
- 권한 확인
- 역할 기반 접근 제어 (RBAC)
- 리소스 접근 관리
3. **User Management Service**
- 사용자 CRUD
- 프로필 관리
- 패스워드 관리
4. **Application Service**
- 애플리케이션 등록/관리
- Client Credentials 관리
- 테마 설정 관리
5. **Audit Service**
- 접속 로그
- 인증 히스토리
- 보안 이벤트 추적
## 확장성 고려사항
### Horizontal Scaling
```mermaid
graph TB
LB[Load Balancer]
subgraph "Application Instances"
App1[App Instance 1]
App2[App Instance 2]
App3[App Instance 3]
end
subgraph "Shared State"
Redis[Redis Session Store]
MongoDB[MongoDB Cluster]
end
LB --> App1
LB --> App2
LB --> App3
App1 --> Redis
App1 --> MongoDB
App2 --> Redis
App2 --> MongoDB
App3 --> Redis
App3 --> MongoDB
```
### Database Sharding
- User ID 기반 샤딩
- Application ID 기반 샤딩
- 시간 기반 파티셔닝 (히스토리)
### Caching Strategy
- User Profile 캐싱
- Application Settings 캐싱
- Token 캐싱
## 보안 아키텍처
```mermaid
graph TB
subgraph "External"
Internet[Internet]
end
subgraph "DMZ"
WAF[WAF]
CDN[CDN]
end
subgraph "Public Subnet"
ALB[Application Load Balancer]
NAT[NAT Gateway]
end
subgraph "Private Subnet"
App[Application Servers]
Cache[Cache Layer]
end
subgraph "Data Subnet"
DB[(Database)]
Backup[(Backup Storage)]
end
Internet --> WAF
WAF --> CDN
CDN --> ALB
ALB --> App
App --> Cache
App --> NAT
App --> DB
DB --> Backup
```
### Network Security
- VPC 격리
- Security Groups
- Private Subnets
### Application Security
- Rate Limiting
- DDoS Protection
- WAF Rules
### Data Security
- Encryption at Rest
- Encryption in Transit
- Key Management Service (KMS)