feat: 회원 시스템 보안 강화 및 Auth-Trip 통합 시나리오 반영#25
Merged
Conversation
- 회원가입/정보 수정 시 Access & Refresh Token 발급 로직 구현
- JwtAuthenticationFilter 내 탈퇴 회원(isDeleted) 실시간 검증 및 차단 추가
- 토큰 내 사용자 정보(ID, 성별, 나이 등) 포함을 위한 엔티티 및 Provider 수정
- 비밀번호 변경 시 기존 모든 리프레시 토큰 삭제로 세션 무효화 처리
- AuthController/Service 내 예외 처리 및 응답 규격(ApiResponse.ok) 준수
- CustomUserDetails 형변환 에러(ClassCastException) 해결 📝 주요 작업 및 수정 내용
1. 회원 생애 주기별 토큰 관리 최적화
회원가입 (createUser): 가입 직후 즉시 서비스를 이용할 수 있도록 Access Token과 Refresh Token을 함께 발급하여 반환합니다.
정보 수정 (updateUser): 성별, 나이 등 변경된 정보가 토큰에 즉시 반영되도록 Access Token을 재발급합니다.
회원 탈퇴 (deleteUser): 탈퇴 시 DB에서 isDeleted 상태를 변경함과 동시에 해당 사용자의 모든 RefreshToken을 즉시 삭제하여 보안을 강화했습니다.
2. 실시간 보안 검증 필터 고도화 (JwtAuthenticationFilter)
탈퇴 회원 차단: 토큰이 기술적으로 유효하더라도 DB 조회를 통해 isDeleted 상태를 확인하여 탈퇴한 회원의 접근을 즉시 차단(401 Unauthorized)합니다.
타입 안정성 확보: 인증 객체에서 memberId를 추출할 때 CustomUserDetails와 String 타입을 모두 안전하게 처리하도록 로직을 수정하여 ClassCastException을 해결했습니다.
3. 신규 기능 및 API 구현
내 정보 조회: GET /users/me API를 통해 현재 로그인한 사용자의 상세 정보를 반환합니다.
비밀번호 검증 및 변경: POST /users/verify-password와 PATCH /users/password를 통해 보안 기능을 강화했습니다. 특히 비밀번호 변경 시 보안을 위해 모든 기존 토큰을 무효화합니다.
4. 예외 처리 및 응답 구조 개선
GlobalExceptionHandler에 BadCredentialsException 핸들러를 추가하여 인증 실패 시 일관된 Member-001 (401) 에러가 반환되도록 했습니다.
AuthController 내 존재하지 않던 success() 메소드 호출을 프로젝트 표준인 ApiResponse.ok()로 전면 수정했습니다.
✅ 테스트 결과 (api-test2.http 기반)
Phase 1~10 통합 테스트 완료: 회원가입부터 탈퇴 후 재가입 방지까지 모든 시나리오 검증.
탈퇴 후 접근 차단: 탈퇴한 회원의 토큰으로 Trip 서비스 및 Auth 서비스 재발급 시도 시 즉시 401 에러 반환 확인.
데이터 정합성: 토큰 및 응답 바디에 gender, age 등 확장된 회원 정보가 정상적으로 포함됨을 확인.
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.
🔍 PR 타입 선택
feat: 새로운 기능 추가 (회원 생애 주기별 토큰 관리 및 신규 API 구현)fix: 버그 수정 (ClassCastException 및 응답 규격 수정)refactor: 코드 리팩토링📝 변경 사항 요약
JwtAuthenticationFilter내isDeleted상태 검증 로직 추가 및 타입 안정성 확보.ApiResponse.ok적용 및 글로벌 예외 핸들러 고도화.🛠 관련 이슈
추가 설명 (상세 작업 내역)
1. 토큰 관리 최적화 및 페이로드 확장
createUser): 가입 직후 Access/Refresh Token을 즉시 발급하여 UX 개선.updateUser): 성별, 나이 등 변경된 정보를 토큰 페이로드에 즉시 반영하기 위해 새 Access Token 발급.Member엔티티 및JwtProvider수정.2. 보안 및 실시간 검증 (Security Strategy)
JwtAuthenticationFilter 고도화:
토큰 서명 검증 후, DB 조회를 통해
isDeleted=true인 회원의 접근을 즉시 차단(401).CustomUserDetails형변환 시 발생하던ClassCastException방어 로직 적용.세션 무효화: 비밀번호 변경 또는 탈퇴 시 해당 사용자의 모든 Refresh Token을 삭제하여 보안 강화.
3. API 및 응답 규격 고도화
GET /users/me,POST /users/verify-password,PATCH /users/password구현.success()호출을 프로젝트 공통 규격인ApiResponse.ok()로 변경.BadCredentialsException발생 시 일관된 에러 코드(Member-001) 반환 설정.4. 테스트 결과
api-test2.http기반 Phase 1~10 통합 테스트 통과.