[feature] 웹 로그인 기반 익스텐션 토큰 발급 API 추가 - #103
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: edfb06410c
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| @ApiBearerAuth() | ||
| @ApiExtensionToken() | ||
| async issueExtensionToken(@CurrentUser() user: AuthUser) { | ||
| return this.authService.issueTokens(user.userId) |
There was a problem hiding this comment.
withdraw()는 기존 refresh token을 삭제하고 사용자에게 deletedAt만 설정하므로, 탈퇴 직전에 발급된 access token은 기본 15분 동안 계속 JwtAuthGuard를 통과합니다. 이 상태에서 해당 사용자가 이 엔드포인트를 호출하면 issueTokens()가 활성 사용자 여부를 확인하지 않고 새 refresh token을 저장하며, 사용자 행은 soft delete되어 FK도 그대로 유효하므로 탈퇴 후에도 30일짜리 세션을 다시 확보할 수 있습니다. 발급 전에 findActiveById()로 계정 상태를 검증하거나 guard에서 탈퇴 사용자를 거부해야 합니다.
AGENTS.md reference: AGENTS.md:L11-L11
Useful? React with 👍 / 👎.
| @ApiBearerAuth() | ||
| @ApiExtensionToken() | ||
| async issueExtensionToken(@CurrentUser() user: AuthUser) { | ||
| return this.authService.issueTokens(user.userId) |
|
|
||
| private async issueTokens( | ||
| // 웹 세션(access token)으로 인증된 사용자에게 익스텐션 전용 토큰쌍을 새로 | ||
| // 발급할 때(POST /auth/extension-token)도 컨트롤러에서 직접 호출한다. 새 |
📌 개요
익스텐션이 웹 로그인 페이지를 거쳐 인증한 뒤, 웹 access token으로 별도의 익스텐션 전용 토큰쌍을 발급받을 수 있는 API를 추가합니다. 웹과 독립된
tokenFamily로 발급되어 한쪽을 로그아웃해도 다른 쪽에는 영향이 없습니다.✅ 작업 내용 및 변경 사항
POST /auth/extension-token추가 (웹 access token으로 인증)issueTokens를 재사용해 새tokenFamily로 발급 → 웹 세션과 독립적으로 회전/폐기jti추가purpose(primary/extension) claim 추가PrimaryAuthGuard추가💬 리뷰어에게
리프레시토큰 스키마에 purpose를 추가해서 익스텐션 토큰 발급을 웹/앱 토큰에 대해서만 수행할 수 있도록 제한했습니다
🔗 관련 이슈
없음
🔍 상세 내용
플로우
로컬 테스트 완료
MASTER_ACCESS_TOKEN인증 우회로 검증POST /auth/extension-token정상 발급 확인tokenFamily로 정상 삽입 (jti 수정 전에는 같은 초에 호출 시 500 재현됨)/auth/refresh로 회전 → 이미 사용된 토큰 재사용 시 탈취로 감지되어 401, 그 사이 별도 family인 다른 토큰쌍은 영향 없이 정상 회전 (독립성 확인)bun test159 pass,tsc --noEmit/eslint클린