Skip to content

Conversation

@hyerinhwang-sailin
Copy link
Collaborator

@hyerinhwang-sailin hyerinhwang-sailin commented Sep 11, 2025

Related issue 🛠

Work Description ✏️

배경

  • 앱에서 액세스 토큰 만료 시 500이 응답되어 클라이언트가 리프레시를 트리거하지 못하는 문제가 있었습니다.
  • 또한 외부 인증/플레이그라운드 API가 401/403을 반환해도 서버에서 500으로 래핑되는 경우가 있어 상태코드가 보존되지 않았습니다.

변경 내용

  1. JwtAuthenticationFilter
  • ExpiredJwtException/JwtException을 BadCredentialsException(AuthenticationException)으로 래핑.
  • SecurityContextHolder.clearContext() 호출로 잔존 인증 제거.
  1. JwtExceptionFilter
  • UnauthorizedException은 ErrorCode의 상태코드로 응답.
  • AuthenticationException은 401 + TOKEN_EXPIRED로 응답.
  • FailureResponse 포맷으로 에러 바디 일관화.
  1. Feign401ErrorDecoder (신규)
  • 외부 API의 401 → UNAUTHORIZED, 403 → FORBIDDEN으로 변환해 도메인 예외로 상위 전달.
  1. GlobalExceptionHandler
  • UnauthorizedException을 내부 ErrorCode의 HttpStatus로 그대로 매핑(401/403 보존).
  1. ClientConfig
  • 세 Feign 클라이언트(Playground/Crew/Platform)에 .errorDecoder(Feign401ErrorDecoder) 적용.
  • 로깅 클래스 정리. (재시도 정책은 기본값 유지)

기대 효과

  • 만료/무효 토큰 요청은 항상 401로 내려가고, 클라이언트에서 자동 리프레시가 정상 동작.
  • 외부 API에서 온 401/403 상태가 서버에서 보존되어, 불필요한 500 발생 방지 및 디버깅/모니터링 용이.

호환성 / 영향 범위

  • 인증이 필요한 엔드포인트의 에러 상태코드가 500→401/403으로 변경됩니다.
  • 정상 플로우에는 영향 없음.

Trouble Shooting ⚽️

Related ScreenShot 📷

Uncompleted Tasks 😅

To Reviewers 📢

@hyerinhwang-sailin hyerinhwang-sailin linked an issue Sep 11, 2025 that may be closed by this pull request
1 task
@height
Copy link

height bot commented Sep 11, 2025

Link Height tasks by mentioning a task ID in the pull request title or commit messages, or description and comments with the keyword link (e.g. "Link T-123").

💡Tip: You can also use "Close T-X" to automatically close a task when the pull request is merged.

@hyerinhwang-sailin hyerinhwang-sailin self-assigned this Sep 11, 2025
@hyerinhwang-sailin hyerinhwang-sailin added the 🛠️ BugFix 버그 해결 label Sep 11, 2025
@hyerinhwang-sailin hyerinhwang-sailin merged commit 42cd149 into dev Sep 11, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] 인증서버 토큰 만료 시 응답코드 수정

1 participant