Update NAVER WORKS API guide with implementation details and security notes
This commit is contained in:
parent
47265ebe76
commit
0680384ee1
@ -128,41 +128,34 @@
|
||||
- **`auth-server/.env`**: NAVERWORKS_CLIENT_ID, SECRET, REDIRECT_URI 추가
|
||||
- **`nginx-deploy`**: `/auth/naverworks`, `/api/naverworks` 라우팅 설정
|
||||
|
||||
#### DB 스키마
|
||||
- **기존 users 테이블 활용**: oauth_provider="naverworks", oauth_id={NAVER WORKS userId}
|
||||
- **신규 테이블**: `team.naverworks_token` (Service Account 토큰 저장용)
|
||||
|
||||
### 5.2 구현 플로우 (Slack 패턴 참조)
|
||||
|
||||
#### OAuth 로그인 플로우
|
||||
```python
|
||||
# auth-server/app/providers/naverworks.py 구현 필요
|
||||
#### OAuth 로그인 엔드포인트
|
||||
- **GET /auth/naverworks/login/**: State 생성 → Redis 저장 → OAuth 리다이렉트
|
||||
- **GET|POST /auth/naverworks/callback**: State 검증 → Token 교환 → Userinfo 조회 → User 매핑 → JWT 발급
|
||||
|
||||
@router.get("/login/")
|
||||
async def naverworks_login():
|
||||
# 1. State 생성 → Redis 저장 (TTL 300s)
|
||||
# 2. Redirect to https://auth.worksmobile.com/oauth2/v2.0/authorize
|
||||
#### Redis Keys
|
||||
- `oauth:state:{state}`: CSRF 방지용 state 저장 (TTL 300s)
|
||||
- `auth:temp:{temp_code}`: Frontend 전달용 임시 코드 (TTL 60s)
|
||||
- `naverworks:service:token`: Service Account 토큰 캐싱 (TTL 3600s)
|
||||
|
||||
@router.get("/callback")
|
||||
@router.post("/callback") # form_post 지원
|
||||
async def naverworks_login_callback():
|
||||
# 1. State 검증
|
||||
# 2. Code → Token 교환 (POST https://auth.worksmobile.com/oauth2/v2.0/token)
|
||||
# 3. Userinfo 조회 (GET https://www.worksapis.com/v1.0/oidc/userinfo)
|
||||
# 4. User DB 매핑 (oauth_provider="naverworks")
|
||||
# 5. JWT 생성 → Redis temp code → Frontend redirect
|
||||
```
|
||||
|
||||
#### Service Account JWT 인증
|
||||
```python
|
||||
async def get_service_account_token():
|
||||
# 1. Private Key 로드 (파일 시스템)
|
||||
# 2. JWT Assertion 생성
|
||||
# 3. Token 요청 (grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer)
|
||||
# 4. Access Token 캐싱 (Redis TTL 3600s)
|
||||
```
|
||||
#### Slack OAuth 참조 파일
|
||||
- **구현 패턴**: `auth-server/app/providers/slack.py`
|
||||
- **Gmail passport**: `auth-server/app/providers/gmail_passport.py`
|
||||
- **JWT 생성**: `auth-server/app/core/auth.py`의 create_access_token()
|
||||
|
||||
### 5.3 결정/확인 필요 사항
|
||||
|
||||
#### 결정사항 (확정)
|
||||
- **Redirect URL 도메인**: `auth.ro-being.com` 사용
|
||||
- **Private Key 저장 경로**: `auth-server/private_20250917185550.key`
|
||||
- **Private Key 처리**:
|
||||
- 2025-09-17: Git 임시 commit 후 서버 전송 완료
|
||||
- 서버 51123 안전 저장: `/secure/naverworks/private_20250917185550.key`
|
||||
- Git에서 삭제 완료 (commit a4a2b9c)
|
||||
- **NAVER WORKS 토큰 테이블**: `naverworks_token` (team 스키마 아래, 단수형)
|
||||
|
||||
#### 확인필요
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user