[김대호] Sprint10 - #142
Open
kdfasdf wants to merge 51 commits into
Open
[김대호] Sprint10#142kdfasdf wants to merge 51 commits into
kdfasdf wants to merge 51 commits into
Conversation
- BasicUserService - BasicChannelService - BasicMessageService - BasicBinaryContentService
- add @Length annotation to request dtos - handle bean validation failures at globalExceptionHandler
refactor : refactoring Mappers
- remove UserStatus domain - invalidate session when user role changed
spring-kang
reviewed
Oct 29, 2025
| import org.springframework.stereotype.Component; | ||
|
|
||
| @Component | ||
| public class JwtProvider { |
Collaborator
There was a problem hiding this comment.
메서드가 명확하게 잘 분리된 것으로 보입니다. 잘 구현하셨습니다.
spring-kang
reviewed
Oct 29, 2025
Comment on lines
+35
to
+36
| if (authorizationHeader != null && authorizationHeader.startsWith(BEARER_PREFIX)) { | ||
| String token = authorizationHeader.substring(BEARER_PREFIX.length()); |
Collaborator
There was a problem hiding this comment.
이것도 별도의 메서드로 분리해주면 더 깔끔할것 같아요
spring-kang
approved these changes
Oct 29, 2025
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.
요구사항
기본
JWT 컴포넌트 구현
implementation 'com.nimbusds:nimbus-jose-jwt:10.3'리팩토링 - 로그인
미션 9와 마찬가지로 Spring Security의 formLogin + 미션 9의 인증 흐름은 그대로 유지하면서 필요한 부분만 대체합니다.
세션 생성 정책을
STATELESS로 변경하고,sessionConcurrency설정을 삭제하세요.AuthenticationSuccessHandler컴포넌트를 대체하세요.기존 구현체는 LoginSuccessHandler입니다.
JwtLoginSuccessHandler를 정의하고 대체하세요.
인증 성공 시 JwtProvider를 활용해 토큰을 발급하세요.
200 JwtDto로 응답합니다.설정에 추가하세요.
JWT 인증 필터 구현
엑세스 토큰을 통해 인증하는 필터(
JwtAuthenticationFilter)를 구현하세요.요청 당 한번만 실행되도록
OncePerRequestFilter를 상속하세요.요청 헤더(
Authorization)에 Bearer 토큰이 포함된 경우에만 인증을 시도하세요.JwtProvider를 통해 엑세스 토큰의 유효성을 검사하세요.유효한 토큰인 경우 UsernamePasswordAuthenticationToken 객체를 활용해 인증 완료 처리하세요.
리프레시 토큰을 활용한 엑세스 토큰 재발급
POST /api/auth/refreshHeader Cookie: REFRESH_TOKEN=…200 JwtDto401 ErrorResponsepermitAll설정에 포함하세요.GET /auth/me)리팩토링 - 로그아웃
쿠키에 저장된 리프레시 토큰을 삭제하는
LogoutHandler를 구현하세요.구현한 핸들러를 추가하세요.
심화 요구사항
리팩토링 - 토큰 상태 관리
JwtAuthenticationFilter에서 JwtRegistry를 활용해 토큰의 상태를 검사하는 로직을 추가하세요.JwtRegistry를 활용해 동시 로그인 제한 기능을 리팩토링하세요.JwtRegistry를 활용해 권한이 변경된 사용자가 로그인 상태라면 강제로 로그아웃되도록 하세요.JwtRegistry를 활용해 사용자의 로그인 여부를 판단하도록 리팩토링하세요.JwtLogoutHandler에서JwtRegistry를 활용해 로그아웃 시 토큰을 무효화하세요.Authentication정보가 없을 수 있습니다.[] 주기적으로 만료된 토큰 정보를 레지스트리에서 삭제하세요.
@EnableScheduling를 추가하세요.@Scheduled를 활용해서 5분마다 만료된 토큰을 삭제하세요.멘토에게