Repository navigation
Conversation
access/refresh 토큰에 tokenType claim(access, refresh)을 넣고, 사용자·admin JWT 필터는 refresh로 명시된 토큰을 유효하지 않은 토큰으로 처리한다. 재발급(AuthService.reissue, AdminAuthService.refresh)은 access로 명시된 토큰을 INVALID_REFRESH_TOKEN으로 거부한다. 배포 전에 발급된 claim 없는 토큰은 access·refresh 양쪽에서 기존처럼 허용한다. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DNr3PM1DZCQLC8RiGJwD3a
탈퇴는 users.status만 DELETED로 바꾸고 email과 행을 유지하므로 CustomUserDetailsService가 findByEmail만으로 탈퇴 사용자를 인증하고 있었다. 살아 있지 않은 사용자는 UsernameNotFoundException으로 거부한다. JwtAuthenticationFilter가 UsernameNotFoundException을 잡지 않아 존재하지 않는 사용자의 토큰이 필터 밖으로 예외를 던져 500이 되던 문제도 요청 attribute exception 설정 후 401로 처리하도록 함께 바로잡는다. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DNr3PM1DZCQLC8RiGJwD3a
존재하지 않는 사용자의 토큰이 500 대신 401로 응답하게 된 변경을 HTTP 경계 테스트에 반영한다. Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DNr3PM1DZCQLC8RiGJwD3a
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
배경
보안 검토에서 인증 토큰 처리의 두 가지 문제를 확인했다.
Authorization: Bearer에 넣으면 인증된다. admin 토큰도 같다.User.status만DELETED로 바꾸고 email과 행을 유지한다.CustomUserDetailsService는findByEmail만 하고isAlive()를 확인하지 않으므로, 탈퇴한 사용자의 토큰이 만료 전까지 인증을 통과한다.변경 동작
커밋 1: refresh 토큰으로 API 인증을 할 수 없게 한다
tokenTypeclaim(access또는refresh)을 넣는다.tokenType이refresh인 토큰을 거부한다. 응답은 기존의 유효하지 않은 토큰과 같다(사용자 체인 401MALFORMED_TOKEN, admin 체인 403).AuthService.reissue,AdminAuthService.refresh)은tokenType이access인 토큰을INVALID_REFRESH_TOKEN으로 거부한다.커밋 2: 탈퇴한 사용자의 토큰으로 인증할 수 없게 한다
CustomUserDetailsService가 살아 있지 않은 사용자에 대해UsernameNotFoundException을 던진다.JwtAuthenticationFilter가UsernameNotFoundException을 잡아 401(JWT_TOKEN_EXCEPTION)로 응답한다. 기존에는 존재하지 않는 사용자의 토큰이 이 예외로 필터 밖까지 나가 500이 됐고, 이 경우도 함께 401이 된다.호환성
tokenTypeclaim이 없는 배포 전 토큰은 access로 계속 받는다. 배포 즉시 전원이 로그아웃되는 것을 피하기 위해서다. 따라서 배포 전에 발급된 refresh 토큰은 만료(최대 14일)까지 Bearer 인증에 쓸 수 있고, 그 뒤에는 claim 없는 토큰 허용을 제거할 수 있다.UserCommandIntegrationTest.test_2("탈퇴한 회원이 다시 탈퇴하는 경우 성공")의 기대값을 401로 바꿨다. 탈퇴 재시도에 200을 기대하는 클라이언트가 있는지 확인이 필요하다.AdminApiSecurityIntegrationTest의 "admin 토큰으로 product API 호출 시UsernameNotFoundException" 단언은 "401 응답" 단언으로 바꿨다.AdminApiHttpBoundaryIntegrationTest는 admin 토큰으로 product 인증 필수 API를 호출할 때의 500을 기존 동작으로 고정하고 있었다. 이 기대값을 401로 바꿨다(커밋 3).범위 밖
CustomAdminUserDetailsService가 던지는UsernameNotFoundException을AdminJwtAuthenticationFilter가 잡지 않는다. 500이 될 가능성이 있다.UserException(INVALID_TOKEN)도 잡지 않는다.검증
a3722c1의ci pipeline(pull_request)이 전체 성공했다: https://github.com/bottle-note/bottle-note-api-server/actions/runs/46381279095e18f0c7의 실행은AdminApiHttpBoundaryIntegrationTest1건이 실패했고, 커밋 3에서 기대값을 맞췄다.추가·수정한 테스트:
JwtTokenValidatorTest,AdminJwtAuthenticationFilterTest,JwtAuthenticationFilterTest,JwtTokenTypeIntegrationTestAuthServiceTest,AdminAuthServiceTest,AdminApiSecurityIntegrationTest,UserCommandIntegrationTesthttps://claude.ai/code/session_01DNr3PM1DZCQLC8RiGJwD3a
Generated by Claude Code