-
Notifications
You must be signed in to change notification settings - Fork 0
π File Directory Refactor #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
μν¬μ€λ£¨μ΄ ν 리νμ€νΈλ μΈμ¦ λ° λ³΄μ κ΄λ ¨ μ½λμ κ΄λ²μν 리ν©ν λ§μ ν¬ν¨ν©λλ€. μ£Όμ λ³κ²½ μ¬νμ DTO ν΄λμ€ μ΄λ¦ λ³κ²½, JWT μμ± κ΅¬μ± λμ , μΏ ν€ κ΄λ¦¬ μ νΈλ¦¬ν° μΆκ°, μ΄λ©μΌ μΈμ¦ νλ‘μΈμ€ κ°μ λ±μ ν¬ν¨ν©λλ€. μ΄λ¬ν λ³κ²½μ μ½λμ ꡬ쑰ν, κ΅¬μ± κ°λ₯μ± λ° μ€λ₯ μ²λ¦¬λ₯Ό ν₯μμν€λ λ° μ€μ μ λκ³ μμ΅λλ€. λ³κ²½ μ¬ν
μ μλ λ μ΄λΈ
κ΄λ ¨ κ°λ₯μ± μλ PR
μνμ€ λ€μ΄μ΄κ·Έλ¨sequenceDiagram
participant Client
participant AuthController
participant AuthService
participant MailService
participant JWTUtil
Client->>AuthController: λ‘κ·ΈμΈ μμ²
AuthController->>AuthService: λ‘κ·ΈμΈ μ²λ¦¬
AuthService->>JWTUtil: ν ν° μμ±
JWTUtil-->>AuthService: ν ν° λ°ν
AuthService-->>AuthController: λ‘κ·ΈμΈ μλ΅
AuthController->>Client: μΈμ¦ μΏ ν€ λ° λ‘κ·ΈμΈ μλ΅
μ (ν λΌμ κ΄μ μμ)
πͺ§ TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 8
π§Ή Nitpick comments (13)
src/main/java/com/mycom/socket/auth/service/data/VerificationData.java (2)
15-17: μ μ ν©ν 리 λ©μλμ ꡬνμ΄ λͺ νν©λλ€λ§, μ ν¨ κΈ°κ°μ μ€μ κ°λ₯νκ² λ§λλ κ²μ΄ μ’κ² μ΅λλ€.CODE_VALID_DURATIONμ μ€μ νμΌμ΄λ νκ²½ λ³μλ₯Ό ν΅ν΄ κ΅¬μ± κ°λ₯νκ² λ§λλ κ²μ κ³ λ €ν΄λ³΄μΈμ. μ΄λ λ€μν νκ²½μμμ μ μ°μ±μ λμ¬μ€ κ²μ λλ€.
27-29: λ©μλ μ΄λ¦μ λ λͺ ννκ² λ³κ²½νλ κ²μ΄ μ’κ² μ΅λλ€.withVerified 보λ€λ createVerifiedCopyλ markAsVerifiedμ κ°μ΄ λ λͺ μμ μΈ μ΄λ¦μ μ¬μ©νλ©΄ λ©μλμ μλλ₯Ό λ μ μ λ¬ν μ μμ κ² κ°μ΅λλ€.
- public VerificationData withVerified() { + public VerificationData createVerifiedCopy() { return new VerificationData(this.code, this.expiryTime, true); }src/main/java/com/mycom/socket/auth/service/MailService.java (3)
72-72: μ΄λ©μΌ μ£Όμμ νμ κ²μ¦μ μΆκ°νλ κ²μ κΆμ₯λ립λλ€.
sendMailλ©μλμμ μ λ¬λ°μ
76-78:verificationDataMapμ λ§λ£λ λ°μ΄ν° μ κ±°λ₯Ό κ³ λ €ν΄λ³΄μΈμ.μΈμ¦ μ½λκ° λ§λ£λκ±°λ μ¬μ©λ νμλ
verificationDataMapμ λ°μ΄ν°κ° λ¨μμμ΄ λ©λͺ¨λ¦¬ λμκ° λ°μν μ μμ΅λλ€. λ§λ£λ λ°μ΄ν°λ μΈμ¦λ λ°μ΄ν°λ₯Ό μ£ΌκΈ°μ μΌλ‘ μ κ±°νλ λ‘μ§μ μΆκ°νλ κ²μ κΆμ₯ν©λλ€.Also applies to: 107-108
117-120:isEmailVerifiedλ©μλμ null μ²΄ν¬ λ° μμΈ μ²λ¦¬ κ²ν
isEmailVerifiedλ©μλμμverificationDataMap.get(email)μ΄nullμΈ κ²½μ°data.isExpired()μμ NullPointerExceptionμ΄ λ°μνμ§ μλλ‘ μμ ν μ κ·Όμ νκ³ μμ΅λλ€. κ·Έλ¬λ μ΄λ©μΌμ΄ μΈμ¦λμ§ μμμ κ²½μ°μ λν λͺ νν μμΈ μ²λ¦¬λ λ‘κ·Έλ₯Ό μΆκ°νλ©΄ λλ²κΉ μ λμμ΄ λ μ μμ΅λλ€.src/main/java/com/mycom/socket/auth/dto/response/RegisterResponse.java (1)
9-11: λ©μμ§ μ²λ¦¬ κ°μ μ μμ±κ³΅ λ©μμ§κ° μ½λμ μ§μ νλμ½λ©λμ΄ μμ΅λλ€. λ€κ΅μ΄ μ§μμ΄λ λ©μμ§ κ΄λ¦¬λ₯Ό μν΄ λ³λμ λ©μμ§ μ€μ νμΌλ‘ λΆλ¦¬νλ κ²μ κ³ λ €ν΄λ³΄μΈμ.
+ private static final String REGISTER_SUCCESS_MESSAGE = "νμκ°μ μ΄ μλ£λμμ΅λλ€."; public static RegisterResponse of(Long memberId, String email, String nickname) { - return new RegisterResponse(memberId, email, nickname, "νμκ°μ μ΄ μλ£λμμ΅λλ€."); + return new RegisterResponse(memberId, email, nickname, REGISTER_SUCCESS_MESSAGE); }src/main/java/com/mycom/socket/auth/security/CookieUtil.java (1)
28-35: λ§λ£ μΏ ν€ μμ± μ 보μ μ€μ κ°μ μ΄ νμν©λλ€.λ§λ£ μΏ ν€ μμ± μ secure μ€μ μ νλμ½λ©νμ§ λ§κ³ JWTPropertiesμμ κ°μ Έμ€λ κ²μ΄ μ’μ΅λλ€.
- cookie.setSecure(true); + cookie.setSecure(jwtProperties.isSecureCookie());src/main/java/com/mycom/socket/auth/jwt/JWTFilter.java (1)
Line range hint
44-52: μΏ ν€ κ²μ¦ λ‘μ§ κ°μ μ΄ νμν©λλ€.null μ²΄ν¬ μΈμλ μΏ ν€ κ°μ μ ν¨μ± κ²μ¦μ μΆκ°νλ κ²μ΄ μ’μ΅λλ€.
private String resolveTokenFromCookie(HttpServletRequest request) { Cookie[] cookies = request.getCookies(); if (cookies != null) { for (Cookie cookie : cookies) { if (jwtProperties.getCookieName().equals(cookie.getName())) { - return cookie.getValue(); + String value = cookie.getValue(); + if (StringUtils.hasText(value)) { + return value; + } } } } return null; }src/main/java/com/mycom/socket/auth/security/LoginFilter.java (1)
Line range hint
44-45: μμΈ λ©μμ§λ₯Ό λ ꡬ체μ μΌλ‘ μμ±ν΄μ£ΌμΈμ.νμ¬ μμΈ λ©μμ§κ° λ무 μΌλ°μ μ λλ€. μ¬μ©μκ° λ¬Έμ λ₯Ό λ μ½κ² νμ ν μ μλλ‘ κ΅¬μ²΄μ μΈ μ 보λ₯Ό μ 곡νλ©΄ μ’κ² μ΅λλ€.
-throw new RuntimeException("λ‘κ·ΈμΈ μμ² μ²λ¦¬ μ€ μ€λ₯κ° λ°μνμ΅λλ€.", e); +throw new RuntimeException("λ‘κ·ΈμΈ μμ² λ°μ΄ν° νμ± μ€ μ€λ₯κ° λ°μνμ΅λλ€. μμ² νμμ νμΈν΄μ£ΌμΈμ.", e);src/test/java/com/mycom/socket/member/service/RegisterServiceTest.java (1)
71-77: λΉλ°λ²νΈ μΈμ½λ© κ²μ¦μ μΆκ°ν΄μ£ΌμΈμ.νμκ°μ μ±κ³΅ ν μ€νΈμμ λΉλ°λ²νΈ μΈμ½λ©μ΄ μ¬λ°λ₯΄κ² μνλμλμ§ κ²μ¦μ΄ λλ½λμμ΅λλ€.
λ€μκ³Ό κ°μ΄ κ²μ¦μ μΆκ°νλ κ²μ μ μν©λλ€:
assertThat(response.email()).isEqualTo(request.email()); assertThat(response.nickname()).isEqualTo(request.nickname()); assertThat(response.message()).isEqualTo("νμκ°μ μ΄ μλ£λμμ΅λλ€."); verify(memberRepository).save(any(Member.class)); verify(mailService).isEmailVerified(request.email()); +verify(passwordEncoder).encode(request.password());src/test/java/com/mycom/socket/member/service/LoginTest.java (1)
65-69: μΏ ν€ μμ±μ μμλ‘ μΆμΆν΄μ£ΌμΈμ.ν μ€νΈμ κ°λ μ±κ³Ό μ μ§λ³΄μμ±μ λμ΄κΈ° μν΄ μΏ ν€ μμ±κ°λ€μ μμλ‘ μΆμΆνλ κ²μ΄ μ’κ² μ΅λλ€.
λ€μκ³Ό κ°μ΄ μμ μ μ μν©λλ€:
+private static final String COOKIE_NAME = "Authorization"; +private static final int COOKIE_MAX_AGE = 1800; +private static final String COOKIE_PATH = "/"; Cookie authCookie = new Cookie("Authorization", token); authCookie.setHttpOnly(true); authCookie.setSecure(true); -authCookie.setPath("/"); -authCookie.setMaxAge(1800); +authCookie.setPath(COOKIE_PATH); +authCookie.setMaxAge(COOKIE_MAX_AGE);src/test/java/com/mycom/socket/member/controller/AuthControllerTest.java (2)
113-119: ν μ€νΈ λ°μ΄ν°μ μμνκ° νμν©λλ€.ν μ€νΈ ν¬νΌ λ©μλμμ μ¬μ©λλ κ³ μ κ°λ€μ μμλ‘ μΆμΆνλ©΄ ν μ€νΈμ μλκ° λ λͺ νν΄μ§ κ² κ°μ΅λλ€.
λ€μκ³Ό κ°μ΄ μμ μ μ μν©λλ€:
+private static final Long TEST_MEMBER_ID = 1L; +private static final String TEST_EMAIL = "[email protected]"; +private static final String TEST_NICKNAME = "testUser"; +private static final String TEST_PASSWORD = "password123"; +private static final String TEST_INTRO = "μλ νμΈμ"; private RegisterRequest createRegisterRequest(String email, String nickname, String password) { - return new RegisterRequest(email, nickname, password, "μλ νμΈμ"); + return new RegisterRequest(email, nickname, password, TEST_INTRO); } private RegisterResponse createRegisterResponse(Long memberId, String email, String nickname) { return RegisterResponse.of(memberId, email, nickname); }
97-110: μκ°κΈ(intro) νλμ λν μ ν¨μ± κ²μ¦ ν μ€νΈλ₯Ό μΆκ°ν΄μ£ΌμΈμ.νμ¬ μ΄λ©μΌ, λλ€μ, λΉλ°λ²νΈμ λν μ ν¨μ± κ²μ¦μ ν μ€νΈλκ³ μμ§λ§, μκ°κΈ νλμ λν κ²μ¦μ΄ λλ½λμμ΅λλ€.
λ€μκ³Ό κ°μ ν μ€νΈ μΌμ΄μ€ μΆκ°λ₯Ό μ μν©λλ€:
@Test @WithMockUser void νμκ°μ _μ€ν¨_μκ°κΈ_κΈΈμ΄μ΄κ³Ό() throws Exception { // given String longIntro = "a".repeat(1001); // 1000μ μ΄κ³Ό RegisterRequest request = createRegisterRequest(TEST_EMAIL, TEST_NICKNAME, TEST_PASSWORD, longIntro); // when ResultActions resultActions = performRegisterRequest(request); // then resultActions .andExpect(status().isBadRequest()) .andExpect(jsonPath("$.message").value("μκ°κΈμ 1000μλ₯Ό μ΄κ³Όν μ μμ΅λλ€.")); }
π Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
π Files selected for processing (24)
src/main/java/com/mycom/socket/auth/config/SecurityConfig.java(3 hunks)src/main/java/com/mycom/socket/auth/controller/AuthController.java(2 hunks)src/main/java/com/mycom/socket/auth/dto/request/EmailRequest.java(1 hunks)src/main/java/com/mycom/socket/auth/dto/request/EmailVerificationRequest.java(1 hunks)src/main/java/com/mycom/socket/auth/dto/request/LoginRequest.java(1 hunks)src/main/java/com/mycom/socket/auth/dto/request/RegisterRequest.java(1 hunks)src/main/java/com/mycom/socket/auth/dto/response/EmailVerificationCheckResponseDto.java(0 hunks)src/main/java/com/mycom/socket/auth/dto/response/EmailVerificationResponse.java(1 hunks)src/main/java/com/mycom/socket/auth/dto/response/EmailVerificationResponseDto.java(0 hunks)src/main/java/com/mycom/socket/auth/dto/response/LoginResponse.java(1 hunks)src/main/java/com/mycom/socket/auth/dto/response/LoginResponseDto.java(0 hunks)src/main/java/com/mycom/socket/auth/dto/response/RegisterResponse.java(1 hunks)src/main/java/com/mycom/socket/auth/jwt/JWTFilter.java(3 hunks)src/main/java/com/mycom/socket/auth/jwt/JWTProperties.java(1 hunks)src/main/java/com/mycom/socket/auth/jwt/JWTUtil.java(2 hunks)src/main/java/com/mycom/socket/auth/security/CookieUtil.java(1 hunks)src/main/java/com/mycom/socket/auth/security/LoginFilter.java(3 hunks)src/main/java/com/mycom/socket/auth/service/AuthService.java(5 hunks)src/main/java/com/mycom/socket/auth/service/MailService.java(3 hunks)src/main/java/com/mycom/socket/auth/service/data/VerificationData.java(1 hunks)src/test/java/com/mycom/socket/member/controller/AuthControllerTest.java(3 hunks)src/test/java/com/mycom/socket/member/service/LoginIntegrationTest.java(3 hunks)src/test/java/com/mycom/socket/member/service/LoginTest.java(4 hunks)src/test/java/com/mycom/socket/member/service/RegisterServiceTest.java(4 hunks)
π€ Files with no reviewable changes (3)
- src/main/java/com/mycom/socket/auth/dto/response/EmailVerificationResponseDto.java
- src/main/java/com/mycom/socket/auth/dto/response/EmailVerificationCheckResponseDto.java
- src/main/java/com/mycom/socket/auth/dto/response/LoginResponseDto.java
β Files skipped from review due to trivial changes (2)
- src/main/java/com/mycom/socket/auth/dto/request/RegisterRequest.java
- src/main/java/com/mycom/socket/auth/dto/request/LoginRequest.java
π Additional comments (17)
src/main/java/com/mycom/socket/auth/service/data/VerificationData.java (2)
7-11: λ μ½λ μ μΈμ΄ μ λμ΄μμ΅λλ€!λΆλ³μ±μ 보μ₯νλ record νμ μ μ¬μ©μ΄ μ μ νλ©°, κ²μ¦ μνλ₯Ό μΆμ νκΈ° μν verified νλμ μΆκ°κ° μ’μ΅λλ€.
19-20: μμ±μ ꡬνμ΄ μ μ ν©λλ€!κΈ°λ³Έ μμ±μκ° μ£Ό μμ±μμκ² μ μ ν μμνκ³ μμΌλ©°, κΈ°λ³Έκ° μ€μ μ΄ μΌκ΄μ± μκ² λμ΄ μμ΅λλ€.
src/main/java/com/mycom/socket/auth/controller/AuthController.java (1)
3-9: μλ‘μ΄ DTO ν΄λμ€κ° μ¬λ°λ₯΄κ² μν¬νΈλμμ΅λλ€.DTO ν΄λμ€λ€μ ν¨ν€μ§ κ²½λ‘ λ° μ΄λ¦ λ³κ²½μ΄ μ ννκ² λ°μλμμ΅λλ€.
src/main/java/com/mycom/socket/auth/service/AuthService.java (1)
50-50: μΏ ν€ μ€μ μ 보μ μ΅μ μ νμΈνμμμ€.
CookieUtilμ μ¬μ©νμ¬ μΏ ν€λ₯Ό μμ±ν λ, μΏ ν€μHttpOnly,Secureμ κ°μ 보μ μμ±μ΄ μ€μ λμ΄ μλμ§ νμΈνλ κ²μ΄ μ’μ΅λλ€. μ΄λ₯Ό ν΅ν΄ μΏ ν€ νμ·¨ λ±μ μνμ μ€μΌ μ μμ΅λλ€.Also applies to: 103-103
src/main/java/com/mycom/socket/auth/dto/response/EmailVerificationResponse.java (1)
3-9:EmailVerificationResponseλ μ½λ μ μκ° μ μ ν©λλ€.κ°κ²°νκ³ λΆλ³ κ°μ²΄λ₯Ό λνλ΄κΈ° μν΄ μλ° λ μ½λλ₯Ό μ¬μ©ν κ²μ μ’μ μ νμ λλ€.
src/main/java/com/mycom/socket/auth/dto/response/LoginResponse.java (1)
3-10:LoginResponseλ μ½λ μ μκ° μ μ ν©λλ€.λ‘κ·ΈμΈ μλ΅ λ°μ΄ν°λ₯Ό κ°κ²°νκ² νννκΈ° μν΄ μλ° λ μ½λλ₯Ό νμ©ν κ²μ ν¨μ¨μ μ λλ€.
src/main/java/com/mycom/socket/auth/dto/request/EmailRequest.java (1)
Line range hint
6-11: DTO μ΄λ¦ λ³κ²½μ΄ μΌκ΄μ± μκ² μ μ©λμμ΅λλ€.ν΄λμ€ μ΄λ¦μμ Dto μ λ―Έμ¬λ₯Ό μ κ±°ν λ³κ²½μ΄ μ 체μ μΈ λ¦¬ν©ν λ§ λ°©ν₯κ³Ό μ μΌμΉν©λλ€. μ΄λ©μΌ μ ν¨μ± κ²μ¬λ μ μ νκ² κ΅¬νλμ΄ μμ΅λλ€.
src/main/java/com/mycom/socket/auth/dto/request/EmailVerificationRequest.java (1)
Line range hint
7-15: μ ν¨μ± κ²μ¬κ° μ ꡬνλμ΄ μμ΅λλ€.μ΄λ©μΌκ³Ό μΈμ¦ μ½λμ λν μ ν¨μ± κ²μ¬κ° μ μ νκ² κ΅¬νλμ΄ μμΌλ©°, μλ¬ λ©μμ§λ λͺ νν©λλ€. 6μ리 μ«μ μ½λμ λν μ κ·μ ν¨ν΄λ μ νν©λλ€.
src/main/java/com/mycom/socket/auth/security/CookieUtil.java (1)
16-23: μΏ ν€ μ€μ μ΄ μ μ νκ² κ΅¬νλμμ΅λλ€.보μ κ΄λ ¨ μ€μ (httpOnly, secure)μ΄ μ μ μ©λμ΄ μμΌλ©°, JWTPropertiesλ₯Ό ν΅ν μ€μ κ΄λ¦¬κ° 체κ³μ μΌλ‘ λμ΄ μμ΅λλ€.
src/main/java/com/mycom/socket/auth/config/SecurityConfig.java (1)
35-38: JWT νν° μ€μ μ΄ μ μ ν©λλ€.JWTPropertiesλ₯Ό ν΅ν μ€μ μ£Όμ μ΄ μ λμ΄μμΌλ©°, νν° μ²΄μΈμ μ¬λ°λ₯΄κ² ν΅ν©λμμ΅λλ€.
src/test/java/com/mycom/socket/member/service/LoginIntegrationTest.java (2)
53-58: ν μ€νΈ μΌμ΄μ€κ° μ ꡬνλμμ΅λλ€.LoginRequestμ LoginResponseλ₯Ό μ¬μ©ν ν μ€νΈ κ΅¬μ‘°κ° λͺ ννλ©°, μ€μ μλΉμ€ λ‘μ§μ μ κ²μ¦νκ³ μμ΅λλ€.
66-68: μ€μ κ° κ²μ¦μ΄ μ μ ν©λλ€.JWTPropertiesμ μ€μ κ°λ€μ μ΄μ©ν μΏ ν€ μμ± κ²μ¦μ΄ 체κ³μ μΌλ‘ ꡬνλμμ΅λλ€.
src/main/java/com/mycom/socket/auth/jwt/JWTFilter.java (2)
Line range hint
28-41: μμΈ μ²λ¦¬μ λ‘κΉ μ΄ κ°μ λμμ΅λλ€.μΈμ¦ μ€ν¨ μμ μμΈ μ²λ¦¬μ λ‘κΉ μ΄ μ μ νκ² κ΅¬νλμμΌλ©°, SecurityContext μ λ¦¬κ° μ¬λ°λ₯΄κ² μνλ©λλ€.
56-68: μΈμ¦ λ‘μ§ λΆλ¦¬κ° μ λμμ΅λλ€.setAuthentication λ©μλλ‘ μΈμ¦ λ‘μ§μ λΆλ¦¬ν κ²μ΄ μ½λ κ°λ μ±κ³Ό μ μ§λ³΄μμ±μ ν₯μμμΌ°μ΅λλ€.
src/main/java/com/mycom/socket/auth/security/LoginFilter.java (1)
56-58: μΏ ν€ μμ± λ‘μ§μ΄ μ κ°μ λμμ΅λλ€!μΏ ν€ μμ± λ‘μ§μ CookieUtilλ‘ λΆλ¦¬ν κ²μ μ’μ 리ν©ν λ§μ λλ€. μ΄λ₯Ό ν΅ν΄:
- μΏ ν€ μ€μ μ μΌκ΄μ± μ μ§
- 보μ κ΄λ ¨ μ€μ μ μ€μν
- μ½λ μ¬μ¬μ©μ± ν₯μ
src/test/java/com/mycom/socket/member/service/RegisterServiceTest.java (1)
80-115: μλ¬ μΌμ΄μ€μ λν ν μ€νΈκ° μ μμ±λμμ΅λλ€!μ΄λ©μΌ λ―ΈμΈμ¦κ³Ό μ€λ³΅ μ΄λ©μΌμ λν ν μ€νΈ μΌμ΄μ€κ° λͺ ννκ² μμ±λμμ΅λλ€. μμΈ λ©μμ§λ ꡬ체μ μ΄κ³ μ΄ν΄νκΈ° μ½κ² μμ±λμμ΅λλ€.
src/test/java/com/mycom/socket/member/service/LoginTest.java (1)
Line range hint
89-126: λ‘κ·ΈμΈ μ€ν¨ ν μ€νΈκ° μ μμ±λμμ΅λλ€!μ€ν¨ μΌμ΄μ€μ λν ν μ€νΈκ° κΌΌκΌΌνκ² μμ±λμμ΅λλ€:
- μ΄λ©μΌ μμ μΌμ΄μ€ κ²μ¦
- μλͺ»λ λΉλ°λ²νΈ μΌμ΄μ€ κ²μ¦
- μ€ν¨ μ μΏ ν€κ° μ€μ λμ§ μλμ§ νμΈ
| public EmailVerificationResponse sendVerificationEmail(@Valid @RequestBody EmailRequest request) { | ||
| return mailService.sendMail(request.email()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π οΈ Refactor suggestion
μμΈ μ²λ¦¬λ₯Ό μΆκ°νμ¬ μμ μ±μ ν₯μμν€μμμ€.
sendVerificationEmail λ©μλμμ μ΄λ©μΌ μ μ‘ μ€ λ°μν μ μλ μμΈμ λν μ²λ¦¬κ° μμ΅λλ€. μ΄λ©μΌ μ μ‘ μ€ν¨ μ μ¬μ©μμκ² μ μ ν νΌλλ°±μ μ 곡ν μ μλλ‘ μμΈ μ²λ¦¬λ₯Ό μΆκ°νλ κ²μ΄ μ’μ΅λλ€.
| public EmailVerificationResponse verifyEmail(@Valid @RequestBody EmailVerificationRequest request) { | ||
| return mailService.verifyCode(request.email(), request.code()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π οΈ Refactor suggestion
μμΈ μ²λ¦¬λ₯Ό μΆκ°νμ¬ μμ μ±μ ν₯μμν€μμμ€.
verifyEmail λ©μλμμ μ΄λ©μΌ κ²μ¦ μ€ λ°μν μ μλ μμΈμ λν μ²λ¦¬κ° μμ΅λλ€. μΈμ¦ μ½λ κ²μ¦ μ€ν¨ μ μ¬μ©μμκ² μ μ ν νΌλλ°±μ μ 곡ν μ μλλ‘ μμΈ μ²λ¦¬λ₯Ό μΆκ°νλ κ²μ΄ μ’μ΅λλ€.
| return true; | ||
| } catch (Exception e) { | ||
| log.warn("JWT ν ν° κ²μ¦ μ€ μλ¬ λ°μ: {}", e.getMessage()); | ||
| log.warn("JWT ν ν° κ²μ¦ μ€ν¨", e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μμΈ λ©μμ§μ λ―Όκ°ν μ λ³΄κ° ν¬ν¨λμ§ μλλ‘ λ‘κ·Έλ₯Ό κ°μ νμμμ€.
validateToken λ©μλμμ μμΈ λ°μ μ μ 체 μμΈλ₯Ό λ‘κ·Έμ κΈ°λ‘νκ³ μμ΅λλ€. μμΈ λ©μμ§μ λ―Όκ°ν μ λ³΄κ° ν¬ν¨λ μ μμΌλ―λ‘, λ‘κ·Έμ μμΈ λ©μμ§λ₯Ό ν¬ν¨νμ§ μκ±°λ μ΅μνμ μ λ³΄λ§ κΈ°λ‘νλ κ²μ΄ μ’μ΅λλ€.
| try { | ||
| javaMailSender.send(message); | ||
| return true; | ||
| }catch (Exception e) { | ||
| throw new BaseException("μ΄λ©μΌ λ°μ‘ μ€ μ€λ₯κ° λ°μνμ΅λλ€: " + e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); | ||
| return EmailVerificationResponse.of("μ΄λ©μΌ μ μ‘ μ±κ³΅"); | ||
| } catch (Exception e) { | ||
| throw new BaseException("μ΄λ©μΌ λ°μ‘ μ€ μ€λ₯κ° λ°μνμ΅λλ€: " + e.getMessage(), | ||
| HttpStatus.INTERNAL_SERVER_ERROR); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π οΈ Refactor suggestion
μμΈ μ²λ¦¬λ₯Ό ꡬ체μ μΈ μμΈλ‘ μ ννλ κ²μ μ μν©λλ€.
νμ¬ sendMail λ©μλμμ λͺ¨λ μμΈλ₯Ό ν¬κ΄νλ Exceptionμ μΊμΉνκ³ μμ΅λλ€. μ΄λ μμΈμ μμΈμ νμ
νκΈ° μ΄λ ΅κ² λ§λ€ μ μμΌλ―λ‘, MailExceptionμ΄λ MessagingExceptionκ³Ό κ°μ ꡬ체μ μΈ μμΈλ₯Ό μΊμΉνμ¬ μ νν μμΈ μ²λ¦¬λ₯Ό κΆμ₯ν©λλ€.
| @ConfigurationProperties(prefix = "jwt") | ||
| public class JWTProperties { | ||
| private String secret; | ||
| private long accessTokenValidityInSeconds = 1800; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π οΈ Refactor suggestion
ν ν° μ ν¨ κΈ°κ°μ λν μ΅μκ° κ²μ¦ νμ
ν ν° μ ν¨ κΈ°κ°μ΄ λ무 μ§§μ§ μλλ‘ μ΅μκ° κ²μ¦μ΄ νμν©λλ€.
- private long accessTokenValidityInSeconds = 1800;
+ @Min(value = 300, message = "ν ν° μ ν¨ κΈ°κ°μ μ΅μ 5λΆ μ΄μμ΄μ΄μΌ ν©λλ€.")
+ private long accessTokenValidityInSeconds = 1800;π Committable suggestion
βΌοΈ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| private long accessTokenValidityInSeconds = 1800; | |
| @Min(value = 300, message = "ν ν° μ ν¨ κΈ°κ°μ μ΅μ 5λΆ μ΄μμ΄μ΄μΌ ν©λλ€.") | |
| private long accessTokenValidityInSeconds = 1800; |
| @Component | ||
| @ConfigurationProperties(prefix = "jwt") | ||
| public class JWTProperties { | ||
| private String secret; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JWT secret νλμ λν μ ν¨μ± κ²μ¬ νμ
JWT secretμ νμ κ°μ΄λ―λ‘ @NotEmpty μ΄λ
Έν
μ΄μ
μ μΆκ°νμ¬ μ ν¨μ± κ²μ¬λ₯Ό μνν΄μΌ ν©λλ€.
- private String secret;
+ @NotEmpty(message = "JWT secretμ νμ κ°μ
λλ€.")
+ private String secret;π Committable suggestion
βΌοΈ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| private String secret; | |
| @NotEmpty(message = "JWT secretμ νμ κ°μ λλ€.") | |
| private String secret; |
| private long accessTokenValidityInSeconds = 1800; | ||
| private String cookieName = "Authorization"; | ||
| private String issuer = "go_socket"; | ||
| private boolean secureCookie = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π‘ Codebase verification
보μ μΏ ν€ μ€μ λ¬Έμ νμΈλ¨
νμ¬ κ΅¬μ±μμ λ€μκ³Ό κ°μ μ¬κ°ν 보μ λ¬Έμ κ° νμΈλμμ΅λλ€:
- JWTPropertiesμ secureCookie κΈ°λ³Έκ°μ΄ falseλ‘ μ€μ λ¨
- νλ‘λμ νκ²½μ ν¬ν¨ν μ΄λ€ νκ²½ μ€μ νμΌμμλ μ΄ κ°μ μ¬μ μνμ§ μμ
- SecurityConfigμμλ μΏ ν€ λ³΄μ μ€μ μ λ³λλ‘ κ΅¬μ±νμ§ μμ
νλ‘λμ νκ²½μ 보μμ μν΄ λ°λμ secureCookieλ₯Ό trueλ‘ μ€μ ν΄μΌ ν©λλ€.
π Analysis chain
보μ μΏ ν€ μ€μ κ²ν νμ
νλ‘λμ
νκ²½μμλ 보μ μΏ ν€λ₯Ό νμ±νν΄μΌ ν©λλ€. νμ¬ κΈ°λ³Έκ°μ΄ falseλ‘ μ€μ λμ΄ μμ΄ λ³΄μμ μνν μ μμ΅λλ€.
π Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check if secureCookie is properly configured in different environments
# Check application properties files for secure cookie configuration
echo "Checking application properties files for secure cookie configuration..."
rg -l "jwt\.secure-cookie"
Length of output: 183
Script:
#!/bin/bash
# Search for various possible property naming patterns
echo "Checking different property naming patterns..."
rg -l "jwt\.(secure-?cookie|cookie\.secure|secureCookie)"
echo -e "\nChecking for application properties/yml files..."
fd -e properties -e yml
echo -e "\nChecking for security configuration classes..."
fd -e java -x grep -l "SecurityConfig\|WebSecurityConfig"
Length of output: 730
Script:
#!/bin/bash
echo "Checking application.yml content..."
cat src/main/resources/application.yml
echo -e "\nChecking application-dev.yml content..."
cat src/main/resources/yaml/application-dev.yml
echo -e "\nChecking SecurityConfig.java for cookie configurations..."
cat src/main/java/com/mycom/socket/auth/config/SecurityConfig.java
Length of output: 2900
| // λ‘κ·ΈμΈ μλ΅ μμ± | ||
| LoginResponse loginResponse = new LoginResponse(member.getEmail(), member.getNickname()); | ||
|
|
||
| response.setContentType(MediaType.APPLICATION_JSON_VALUE); | ||
| response.setCharacterEncoding("UTF-8"); | ||
| objectMapper.writeValue(response.getWriter(), ApiResponse.success("λ‘κ·ΈμΈ μ±κ³΅", loginResponse)); | ||
| objectMapper.writeValue(response.getWriter(), loginResponse); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π οΈ Refactor suggestion
μλ΅ μ²λ¦¬μ μμΈ μ²λ¦¬λ₯Ό μΆκ°ν΄μ£ΌμΈμ.
objectMapper.writeValue() νΈμΆ μ λ°μν μ μλ IOExceptionμ λν μμΈ μ²λ¦¬κ° νμν©λλ€.
λ€μκ³Ό κ°μ΄ μμ μ μ μν©λλ€:
// λ‘κ·ΈμΈ μλ΅ μμ±
LoginResponse loginResponse = new LoginResponse(member.getEmail(), member.getNickname());
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
response.setCharacterEncoding("UTF-8");
-objectMapper.writeValue(response.getWriter(), loginResponse);
+try {
+ objectMapper.writeValue(response.getWriter(), loginResponse);
+} catch (IOException e) {
+ throw new RuntimeException("λ‘κ·ΈμΈ μλ΅ μμ± μ€ μ€λ₯κ° λ°μνμ΅λλ€.", e);
+}π Committable suggestion
βΌοΈ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // λ‘κ·ΈμΈ μλ΅ μμ± | |
| LoginResponse loginResponse = new LoginResponse(member.getEmail(), member.getNickname()); | |
| response.setContentType(MediaType.APPLICATION_JSON_VALUE); | |
| response.setCharacterEncoding("UTF-8"); | |
| objectMapper.writeValue(response.getWriter(), ApiResponse.success("λ‘κ·ΈμΈ μ±κ³΅", loginResponse)); | |
| objectMapper.writeValue(response.getWriter(), loginResponse); | |
| // λ‘κ·ΈμΈ μλ΅ μμ± | |
| LoginResponse loginResponse = new LoginResponse(member.getEmail(), member.getNickname()); | |
| response.setContentType(MediaType.APPLICATION_JSON_VALUE); | |
| response.setCharacterEncoding("UTF-8"); | |
| try { | |
| objectMapper.writeValue(response.getWriter(), loginResponse); | |
| } catch (IOException e) { | |
| throw new RuntimeException("λ‘κ·ΈμΈ μλ΅ μμ± μ€ μ€λ₯κ° λ°μνμ΅λλ€.", e); | |
| } |
π κ΄λ ¨ μ΄μ
#28 μ½λ ꡬ쑰 κ°μ
β¨ κ³Όμ λ΄μ©
κΈ°μ‘΄μ μ½λ λλΉμ΄ μ μν΄μ€ μ½λλ₯Ό ν΄κ²°νλλ°λ§ μ§μ€νμ¬ μ μ
λΆνμν μ½λλ€μ΄λ μ½λλ€μ΄ λ€μ£½λ°μ£½ λμ΄κ°μ μ½λ ꡬ쑰 λ° κΈ°μ‘΄ μ½λλ€κ³Ό ν¨κ» ν΅μΌν νλ κ³Όμ μ λλ€.
πΈ μ€ν¬λ¦°μ·(μ ν)
π λ νΌλ°μ€ (λλ μλ‘ μκ² λ λ΄μ©) νΉμ κΆκΈν μ¬νλ€
Summary by CodeRabbit
λ¦΄λ¦¬μ¦ λ ΈνΈ
μλ‘μ΄ κΈ°λ₯
κ°μ μ¬ν
λ²κ·Έ μμ