Conversation
There was a problem hiding this comment.
Pull request overview
JWT 기반 인증(로그인/회원가입)과 Security 설정을 토큰 기반(STATELESS)으로 전환하고, 인증된 사용자 정보를 활용하도록 마이페이지 API를 리팩토링한 PR입니다.
Changes:
- JJWT 기반 토큰 생성/검증 유틸(
JwtUtil) 및 인증 필터(JwtAuthFilter) 추가 SecurityConfig를 STATELESS로 전환하고 JWT 필터 체인에 등록- 로그인 API/DTO/컨버터 추가 및 마이페이지를
@AuthenticationPrincipal기반으로 변경
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main/java/com/example/umc10th/global/security/util/JwtUtil.java | JWT 생성/파싱 유틸 추가 |
| src/main/java/com/example/umc10th/global/security/filter/JwtAuthFilter.java | Authorization 헤더 기반 인증 처리 필터 추가 |
| src/main/java/com/example/umc10th/global/config/SecurityConfig.java | 세션 비활성화(STATELESS), JWT 필터 등록, permitAll 경로 조정 |
| src/main/java/com/example/umc10th/domain/member/service/MemberService.java | 로그인 로직 추가 및 마이페이지 서비스 시그니처 변경 |
| src/main/java/com/example/umc10th/domain/member/controller/MemberController.java | 마이페이지 principal 기반 변경 + 로그인 엔드포인트 추가 |
| src/main/java/com/example/umc10th/domain/member/dto/MemberReqDTO.java | 로그인 요청 DTO 추가 |
| src/main/java/com/example/umc10th/domain/member/dto/MemberResDTO.java | 로그인 응답 DTO 추가 |
| src/main/java/com/example/umc10th/domain/member/converter/MemberConverter.java | 로그인 응답 변환 추가 |
| src/main/java/com/example/umc10th/domain/member/exception/code/MemberSuccessCode.java | 로그인 성공 코드 추가(중복 코드 이슈 존재) |
| src/main/java/com/example/umc10th/domain/member/exception/code/MemberErrorCode.java | 비밀번호 불일치 에러 코드 추가 |
| src/main/java/com/example/umc10th/domain/member/entity/Member.java | social_type 컬럼 길이 지정 |
| build.gradle | JJWT 및 configuration processor 의존성 추가 |
Comments suppressed due to low confidence (1)
src/main/java/com/example/umc10th/global/config/SecurityConfig.java:69
- STATELESS + formLogin 비활성화 상태에서
logoutSuccessUrl("/login?logout")로 리다이렉트하면/login엔드포인트가 없어서 404가 날 수 있습니다. 토큰 기반 API라면 로그아웃을 비활성화하거나(클라이언트에서 토큰 폐기) 별도 성공 핸들러로 200을 반환하도록 맞추는 편이 일관적입니다.
.logout(logout -> logout
.logoutUrl("/logout")
.logoutSuccessUrl("/login?logout")
.permitAll()
);
Comment on lines
12
to
16
| SIGN_UP(HttpStatus.OK, "MEMBER200_1", "회원가입에 성공했습니다."), | ||
| GET_HOME(HttpStatus.OK, "MEMBER200_2", "홈 화면 조회에 성공했습니다."), | ||
| GET_MY_PAGE(HttpStatus.OK, "MEMBER200_3", "성공적으로 유저를 조회했습니다."); | ||
| GET_MY_PAGE(HttpStatus.OK, "MEMBER200_3", "성공적으로 유저를 조회했습니다."), | ||
| LOGIN(HttpStatus.OK, "MEMBER200_2", "로그인에 성공했습니다."); | ||
|
|
Comment on lines
+59
to
+63
| // 5. 다음 필터로 | ||
| filterChain.doFilter(request, response); | ||
|
|
||
| } catch (Exception e) { | ||
| // 토큰 파싱 실패 / 만료 / 서명 불일치 등 → 401 응답통일 |
Comment on lines
+46
to
+48
| // 3. "Bearer " 떼기 | ||
| token = token.replace("Bearer ", ""); | ||
|
|
Comment on lines
35
to
38
| "/v3/api-docs/**", | ||
| "/auth/**", | ||
| "/api/v1/auth/**", // 회원가입 + 로그인 = 인증 없이 허용 | ||
|
|
Comment on lines
+26
to
+32
| public JwtUtil( | ||
| @Value("${jwt.token.secretKey}") String secret, | ||
| @Value("${jwt.token.expiration.access}") Long accessExpiration | ||
| ) { | ||
| this.secretKey = Keys.hmacShaKeyFor(secret.getBytes(StandardCharsets.UTF_8)); | ||
| this.accessExpiration = Duration.ofMillis(accessExpiration); | ||
| } |
CokaNuri
approved these changes
Jun 1, 2026
CokaNuri
left a comment
There was a problem hiding this comment.
JWT 인증 필터를 생성해 SecurityConfig에 JWT 필터를 잘 삽입하셨습니다!
마이페이지도 @AuthenticationPrincipal로 인증객체를 받아 처리하는걸로 잘 수정하셨어요!
로그인 관련해서 자주 등장하는 개념인 CORS에 대해서도 공부해보시면 좋을 것 같아요.
고생하셨습니다!
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 기반 인증 구현
#️⃣ 연관된 이슈
closes #132
💡 함께 공유하고 싶은 부분
🤔 질문
✅ 워크북 체크리스트
✅ 컨벤션 체크리스트
📌 주안점