diff --git a/troubleshooting/250911_happybell80_PostgreSQL_테이블명_단수형_통일.md b/troubleshooting/250911_happybell80_PostgreSQL_테이블명_단수형_통일.md index 96b9f28..80d9c8a 100644 --- a/troubleshooting/250911_happybell80_PostgreSQL_테이블명_단수형_통일.md +++ b/troubleshooting/250911_happybell80_PostgreSQL_테이블명_단수형_통일.md @@ -88,7 +88,7 @@ | robeing-gateway/app/main.py | 522-525 | SELECT bot_token FROM slack_workspaces WHERE team_id = $1 | | robeing-gateway/app/main.py | 567-570 | SELECT bot_token FROM slack_workspaces WHERE team_id = $1 | -### 2.6 gmail_token 테이블 (실제 DB: gmail_token, 0건) +### 2.6 gmail_token 테이블 (실제 DB: gmail_token, 3건) **실제 DB 컬럼**: user_id(FK), token_data(jsonb), oauth_config(jsonb), created_at, updated_at **코드 혼용**: auth-server는 gmail_tokens(복수)와 gmail_token(단수) 혼용 diff --git a/troubleshooting/250913_happybell80_email_skill_auth_cron_errors.md b/troubleshooting/250913_happybell80_email_skill_auth_cron_errors.md index 64198b2..4117041 100644 --- a/troubleshooting/250913_happybell80_email_skill_auth_cron_errors.md +++ b/troubleshooting/250913_happybell80_email_skill_auth_cron_errors.md @@ -10,10 +10,10 @@ ### Email Skill HTTP 500 오류 - **증상**: skill_email 서비스가 HTTP 500 반환 - **에러**: `No credentials found for user: 0914eagle@gmail.com` -- **영향**: 3명 사용자 이메일 동기화 실패 (매분 재시도 중) - - happybell80 (goeun2dc@gmail.com) - - 0914eagle (0914eagle@gmail.com) - - cdctfm (cdctfm@gmail.com) +- **영향**: 3명 사용자 이메일 동기화 실패 + - 0914eagle (0914eagle@gmail.com) - 토큰 있음, 만료 + - happybell80 (goeun2dc@gmail.com) - 토큰 있음, 만료 + - cdctfm (cdctfm@gmail.com) - 토큰 없음 ### Cron 트리거 권한 오류 - **증상**: `Unauthorized cron trigger attempt` 경고 발생 @@ -34,9 +34,9 @@ FROM gmail_token # 테이블명 맞음: 실제 DB도 gmail_token (단수형) WHERE slack_user_id = %s AND is_equipped = true ``` -1. **테이블명 일치 확인**: 코드와 DB 모두 `gmail_token` (250911 문서 확인) -2. **토큰 데이터 구조**: token_data JSONB 내부에 저장 (250909 문서 확인) -3. **is_equipped 조건**: 토큰이 있어도 장착되지 않으면 조회 실패 +1. **테이블명 일치**: 코드와 DB 모두 `gmail_token` 단수형 +2. **토큰 현황**: 2명 refresh_token 보유 (0914eagle, happybell80), 1명 없음 (cdctfm) +3. **만료 상태**: 3명 전원 access_token 만료 (08-18~08-23 생성) ### Cron 인증 취약점 ```python @@ -61,32 +61,30 @@ if auth_header != f"Bearer {expected_token}": ### 즉시 조치 (로컬 개발자) ```python -# 1. 테이블명은 이미 맞음 (gmail_token 단수형) -# 실제 문제: 데이터가 없거나 is_equipped=false +# 1. refresh_token으로 access_token 자동 갱신 구현 필요 +# skill-email/services/gmail_service.py:62-66 +if creds and creds.expired and creds.refresh_token: + creds.refresh(Request()) # 이미 구현되어 있음 -# 2. Cron 인증 강화 -# rb8001/main.py:560 -- # raise HTTPException(status_code=401, detail="Unauthorized") -+ raise HTTPException(status_code=401, detail="Unauthorized") +# 2. Cron 문제는 해결됨 (엔드포인트 삭제 완료) ``` ### 서버 작업 필요 (서버 관리자) ```sql --- 토큰 상태 확인 -SELECT slack_user_id, is_equipped, - token_data->>'refresh_token' IS NOT NULL as has_token -FROM gmail_tokens -WHERE slack_user_id IN ('0914eagle', 'happybell80', 'cdctfm'); +-- 현재 상태: 0914eagle, happybell80는 refresh_token 있음 +-- cdctfm은 토큰 없어 재인증 필요 --- is_equipped 설정 -UPDATE gmail_tokens +-- is_equipped 설정 (토큰 있는 사용자만) +UPDATE gmail_token SET is_equipped = true -WHERE slack_user_id IN ('0914eagle', 'happybell80', 'cdctfm'); +WHERE slack_user_id IN ('0914eagle', 'happybell80'); + +-- cdctfm은 Gmail 재인증 필요 ``` ## 5. 교훈 -1. **DB 현황**: gmail_token 테이블 0건, 데이터 없음 -2. **auth-server**: gmail_tokens와 gmail_token 혼용 (gmail_refresh.py는 복수, gmail_passport.py는 단수) -3. **skill-email**: gmail_token 단수형 사용 (정상) -4. **실제 원인**: 데이터 부재가 문제 (테이블명 아님) \ No newline at end of file +1. **DB 현황**: gmail_token 테이블 3건 (2명 토큰 보유, 1명 없음) +2. **토큰 상태**: 전원 access_token 만료, refresh_token 자동 갱신 필요 +3. **auth-server**: gmail_tokens와 gmail_token 혼용 중 +4. **해결 방법**: is_equipped=true 설정 + refresh 로직 활용 \ No newline at end of file