Skip to content

[fix] #270 - 구글 토큰 폐기 outbox에 토큰을 암호화하여 저장 - #271

Merged
Jy000n merged 1 commit into
developfrom
fix/#270-encrypt-revocation-token
Nov 23, 2026
Merged

Jy000n merged 1 commit into
developfrom
fix/#270-encrypt-revocation-token

Conversation

@Jy000n

@Jy000n Jy000n commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

관련 이슈 🛠

작업 내용 요약 ✏️

  • 회원 탈퇴·구글 캘린더 연동 해제 시 구글 토큰 폐기 요청을 임시로 적어 두는 calendar_revocation_outbox 테이블의 token 컬럼이 평문으로 저장되고 있었습니다.
  • 원본인 GoogleCalendarConnection의 accessToken·refreshToken은 AesGcmConverter로 암호화되어 있는데, outbox는 적용이 빠져 있어 DB 유출·백업·DB 접근 권한자에게 토큰이 그대로 노출될 수 있었습니다.
  • outbox의 token에도 같은 AesGcmConverter를 적용해 암호화하여 저장하도록 수정했습니다.

주요 변경 사항 🛠️

  • [Calendar] : GoogleTokenRevocationOutbox.token에 @Convert(converter = AesGcmConverter.class) 적용

트러블 슈팅 ⚽️

테스트 결과 📄

  • ./gradlew build 통과

스크린샷 📷

리뷰 요구사항 📢

배포 전 확인 사항

  • 배포 직전 운영 DB에서 outbox 상태별 개수를 확인하고, PENDING이 0이 될 때까지 기다린 뒤 배포합니다.
    • 이유: 이 수정 이후 서버는 token을 복호화해서 읽는데, 기존 PENDING 평문 행이 남아 있으면 복호화에 실패해 스케줄러의 폐기 처리가 전부 중단됩니다.

(코리 반영 추가 내용)

배포 순서

  1. 배포 직전 운영 DB에서 outbox 상태별 개수를 확인하고, PENDING이 0이 될 때까지 기다린 뒤 배포합니다.
  2. 구컨테이너가 내려간 직후 PENDING을 다시 확인합니다. 전환 중에 구버전이 쓴 평문 행이 남아 있으면 조회 후 수동으로 정리합니다.
  3. 기존 평문 행을 정리합니다. COMPLETED는 삭제하고, FAILED는 수동 revoke 후 삭제합니다.
  4. 서버 로그에 "토큰 복호화에 실패했습니다"가 없는지 확인합니다.

📎 참고 자료 (선택)

@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@Jy000n
Jy000n force-pushed the fix/#270-encrypt-revocation-token branch from cd968a6 to 536740a Compare November 22, 2026 09:18
@Jy000n

Jy000n commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

브랜치를 실수로 develop 말고 바로 방금 작업하던 refactor/#243-remove-unused-calendar-api에서 분기해버려서 #243 커밋 2개가 함께 올라가 있었습니다. develop 기준으로 브랜치를 다시 맞추고 이 PR의 커밋(GoogleTokenRevocationOutbox 암호화)만 남기려고 force push 했습니다.. 참고해주시면 감사하겠습니다..🥲

@laura-jung laura-jung left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

빠른 수정 감사합니다!

@Column(name = "id")
private Long id;

@Convert(converter = AesGcmConverter.class)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요 컨버터가 요기에만 없었더라고요! 확인 감사합니당

@aneykrap aneykrap left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

신경써야 할게 꽤나 있네용 혹시 모를 예외사항으로 한번 더 확인해보면 좋을것 같은 부분을 인라인 코멘트로 남겨두었습니다! 한번 확인 해주시면 감사하겠습니다 고생많으셨습니다!

@Column(name = "id")
private Long id;

@Convert(converter = AesGcmConverter.class)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p3) 배포 전 확인 사항에 PENDING이 0개 될 때까지 기다렸다가 배포한다고 적어주셨는데 찾아보니 좀 생각해볼만한 상황이 있을것 같아 코멘트 남깁니다!

지금 deploy.sh가 블루그린 방식이라 새 컨테이너 기동 → health check(최대 180초) → nginx 전환 → 10초 뒤 이전 컨테이너 정지 순서로 진행되고 있는데 그 사이에는 이전 버전 서버가 계속 트래픽을 받고 있어서 회원 탈퇴나 연동 해제가 들어오면 평문 PENDING 행이 새로 생길 수 있다고 합니다. 그리고 그동안 두 컨테이너의 GoogleTokenRevocationScheduler가 같이 돌고 있어서 새 서버 스케줄러가 findTop50ByStatus로 그 평문 행을 읽는 순간 복호화 예외로 배치 전체가 실패하고 그 행이 PENDING으로 계속 남아 있으니까 이전 컨테이너가 내려간 뒤에도 매분 계속 실패할수 있다고 해요

배포가 끝난 뒤(이전 컨테이너 정지 후)에 PENDING 행을 한 번 더 확인하면 좋을것 같습니다

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

converter를 뒤늦게 달아서 생기는 문제네요.... 코드 추가는 필요 없을 것 같고 db에서 쿼리로 조회 후에 pending 행들은 수동으로 지우는 작업이 진행되면 좋을 것 같습니다. (아마 지금 탈퇴하는 사용자가 없어서 거의 없을 것 같아요!)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

꼼꼼한 리뷰들 감사드립니당
배포 후 이전 컨테이너 정지 후 PENDING이 남아 있으면 조회 후 수동으로 정리하도록 하겠습니다

private Long id;

@Convert(converter = AesGcmConverter.class)
@Column(name = "token", nullable = false, length = 2048)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p3) 이번 수정으로는 새로 쌓이는 행만 암호화되고 이미 쌓여 있는 COMPLETED/FAILED 행의 token은 평문 그대로 DB에 남아 있을 것 같아요. 스케줄러는 PENDING만 읽어서 복호화 문제는 없겠지만 FAILED는 폐기에 실패한 토큰이라 아직 유효할 수도 있어서 이슈에서 말씀하신 노출 위험이 기존 행에는 그대로 남아 있는 것 같습니당

배포 후에 기존 평문 행도 정리(FAILED는 수동으로 revoke 후 삭제 등)하는 작업도 한번 확인해보시면 좋을것 같아요

@Jy000n Jy000n Nov 23, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵넵 감사합니다
배포 후 COMPLETED는 삭제하고, FAILED은 수동 revoke 후 삭제 작업 확인해서 진행하도록 하겠습니다!!

@github-actions github-actions Bot added the slack-approval-notified Slack 승인 완료 알림 중복 방지용 라벨 label Nov 23, 2026
@Jy000n
Jy000n merged commit 5d0d79a into develop Nov 23, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🌸 자윤 🛠️ fix slack-approval-notified Slack 승인 완료 알림 중복 방지용 라벨

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[fix] 구글 토큰 폐기 outbox에 토큰을 암호화하여 저장

3 participants