✨ Add: 소셜 로그인 (카카오/애플) 기능 추가 #49
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📋 Summary
카카오/애플 소셜 로그인과 JWT 기반 인증 시스템을 구현했습니다.
사용자 계정 관리, 다중 소셜 계정 연동, 디바이스 기반 로그인을 지원합니다.
🎯 주요 기능
🏗️ 아키텍처
erDiagram User ||--o{ OAuthAccount : "has" User ||--o{ DeviceAccount : "has" User ||--o{ RefreshToken : "has" User { bigint id PK varchar nickname varchar profile_image_url varchar status timestamp created_at timestamp updated_at } OAuthAccount { bigint id PK bigint user_id FK varchar provider varchar provider_id varchar email varchar apple_auth_code timestamp created_at timestamp updated_at } DeviceAccount { bigint id PK bigint user_id FK varchar device_id varchar device_type timestamp created_at timestamp updated_at } RefreshToken { bigint id PK bigint user_id FK varchar token timestamp expires_at timestamp created_at timestamp updated_at }User (사용자)
├── OAuthAccount (소셜 계정) 1:N
├── DeviceAccount (디바이스) 1:N
└── RefreshToken (리프레시 토큰) 1:N
auth/
├── JwtTokenProvider - JWT 토큰 생성/검증
├── JwtAuthenticationFilter - JWT 인증 필터
├── SecurityConfig - Spring Security 설정
├── AuthController - 토큰 관리 API
└── AuthService - 토큰 갱신/로그아웃
user/
├── User, OAuthAccount, DeviceAccount - 도메인 모델
├── RefreshToken - 리프레시 토큰 (User 도메인으로 이동)
├── UserController - 사용자 API
├── UserService - 비즈니스 로직
└── AdminUserController - 관리자 API
📡 API 엔드포인트
인증 API (인증 불필요)
사용자 API (인증 필요)
관리자 API
📝 주요 변경사항
implementation("org.springframework.boot:spring-boot-starter-security")
implementation("io.jsonwebtoken:jjwt-api:0.12.3")
runtimeOnly("io.jsonwebtoken:jjwt-impl:0.12.3")
runtimeOnly("io.jsonwebtoken:jjwt-jackson:0.12.3")
jwt:
secret: ${JWT_SECRET}
access-token-expiration: 3600000 # 1시간
refresh-token-expiration: 604800000 # 7일
🧪 테스트 방법
curl 예제
소셜 로그인
curl -X POST http://localhost:8080/api/users/auth/social
-H "Content-Type: application/json"
-d '{
"provider": "KAKAO",
"providerId": "kakao_123",
"nickname": "테스트유저",
"deviceId": "device_001",
"deviceType": "IOS"
}'
프로필 조회
curl -X GET http://localhost:8080/api/users/1/profile
-H "Authorization: Bearer {accessToken}"
🔜 향후 개선 사항