Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mycom.socket.auth.config;

import com.mycom.socket.auth.jwt.JWTFilter;
import com.mycom.socket.auth.jwt.JWTProperties;
import com.mycom.socket.auth.jwt.JWTUtil;
import com.mycom.socket.auth.service.MemberDetailsService;
import lombok.RequiredArgsConstructor;
Expand All @@ -20,6 +21,7 @@
public class SecurityConfig{

private final JWTUtil jwtUtil;
private final JWTProperties properties;
private final MemberDetailsService memberDetailsService;

@Bean
Expand All @@ -30,7 +32,10 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
.httpBasic(AbstractHttpConfigurer::disable)
.formLogin(AbstractHttpConfigurer::disable)

.addFilterBefore(new JWTFilter(jwtUtil, memberDetailsService), UsernamePasswordAuthenticationFilter.class)
.addFilterBefore(
new JWTFilter(properties, jwtUtil, memberDetailsService),
UsernamePasswordAuthenticationFilter.class
)

.sessionManagement(session ->
session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
Expand Down
51 changes: 18 additions & 33 deletions src/main/java/com/mycom/socket/auth/controller/AuthController.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package com.mycom.socket.auth.controller;

import com.mycom.socket.auth.dto.request.EmailRequestDto;
import com.mycom.socket.auth.dto.request.EmailVerificationRequestDto;
import com.mycom.socket.auth.dto.request.LoginRequestDto;
import com.mycom.socket.auth.dto.request.RegisterRequestDto;
import com.mycom.socket.auth.dto.response.EmailVerificationCheckResponseDto;
import com.mycom.socket.auth.dto.response.EmailVerificationResponseDto;
import com.mycom.socket.auth.dto.response.LoginResponseDto;
import com.mycom.socket.auth.dto.request.EmailRequest;
import com.mycom.socket.auth.dto.request.EmailVerificationRequest;
import com.mycom.socket.auth.dto.request.LoginRequest;
import com.mycom.socket.auth.dto.request.RegisterRequest;
import com.mycom.socket.auth.dto.response.EmailVerificationResponse;
import com.mycom.socket.auth.dto.response.LoginResponse;
import com.mycom.socket.auth.dto.response.RegisterResponse;
import com.mycom.socket.auth.service.AuthService;
import com.mycom.socket.auth.service.MailService;
import com.mycom.socket.auth.service.RateLimiter;
import com.mycom.socket.global.exception.BaseException;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
Expand All @@ -23,44 +21,31 @@ public class AuthController {

private final AuthService authService;
private final MailService mailService;
private final RateLimiter rateLimiter;

@PostMapping("/login")
public LoginResponseDto login(@Valid @RequestBody LoginRequestDto request,
HttpServletResponse response) {
public LoginResponse login(@Valid @RequestBody LoginRequest request,
HttpServletResponse response) {
return authService.login(request, response);
}

@PostMapping("/register")
public RegisterResponse register(@Valid @RequestBody RegisterRequest request) {
return authService.register(request);
}

@PostMapping("/logout")
public void logout(HttpServletResponse response) {
authService.logout(response);
}

@PostMapping("/register")
public Long register(@Valid @RequestBody RegisterRequestDto request) {
return authService.register(request);
}

@PostMapping("/verification")
public EmailVerificationResponseDto mailSend(@Valid @RequestBody EmailRequestDto emailRequestDto) {
try {
boolean isSuccess = mailService.sendMail(emailRequestDto.email());
return isSuccess ? EmailVerificationResponseDto.createSuccessResponse() : EmailVerificationResponseDto.createFailureResponse("์ด๋ฉ”์ผ ์ „์†ก์— ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค.");
} catch (BaseException e) {
return EmailVerificationResponseDto.createFailureResponse(e.getMessage());
}
public EmailVerificationResponse sendVerificationEmail(@Valid @RequestBody EmailRequest request) {
return mailService.sendMail(request.email());
Comment on lines +42 to +43
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๐Ÿ› ๏ธ Refactor suggestion

์˜ˆ์™ธ ์ฒ˜๋ฆฌ๋ฅผ ์ถ”๊ฐ€ํ•˜์—ฌ ์•ˆ์ •์„ฑ์„ ํ–ฅ์ƒ์‹œํ‚ค์‹ญ์‹œ์˜ค.

sendVerificationEmail ๋ฉ”์„œ๋“œ์—์„œ ์ด๋ฉ”์ผ ์ „์†ก ์ค‘ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ๋Š” ์˜ˆ์™ธ์— ๋Œ€ํ•œ ์ฒ˜๋ฆฌ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค. ์ด๋ฉ”์ผ ์ „์†ก ์‹คํŒจ ์‹œ ์‚ฌ์šฉ์ž์—๊ฒŒ ์ ์ ˆํ•œ ํ”ผ๋“œ๋ฐฑ์„ ์ œ๊ณตํ•  ์ˆ˜ ์žˆ๋„๋ก ์˜ˆ์™ธ ์ฒ˜๋ฆฌ๋ฅผ ์ถ”๊ฐ€ํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.

}

@PostMapping("/email/verify")
public EmailVerificationCheckResponseDto mailCheck(@Valid @RequestBody EmailVerificationRequestDto emailRequestDto) {
try{
rateLimiter.checkRateLimit(emailRequestDto.email());// ์‹œ๋„ ํšŸ์ˆ˜ ์ œํ•œ
boolean isVerified = mailService.verifyCode(emailRequestDto.email(), emailRequestDto.code());
return isVerified ? EmailVerificationCheckResponseDto.createSuccessResponse() :
EmailVerificationCheckResponseDto.createFailureResponse("์ด๋ฉ”์ผ ์ธ์ฆ์— ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค.");
}catch (BaseException e){
return EmailVerificationCheckResponseDto.createFailureResponse(e.getMessage());
}
public EmailVerificationResponse verifyEmail(@Valid @RequestBody EmailVerificationRequest request) {
return mailService.verifyCode(request.email(), request.code());
Comment on lines +47 to +48
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๐Ÿ› ๏ธ Refactor suggestion

์˜ˆ์™ธ ์ฒ˜๋ฆฌ๋ฅผ ์ถ”๊ฐ€ํ•˜์—ฌ ์•ˆ์ •์„ฑ์„ ํ–ฅ์ƒ์‹œํ‚ค์‹ญ์‹œ์˜ค.

verifyEmail ๋ฉ”์„œ๋“œ์—์„œ ์ด๋ฉ”์ผ ๊ฒ€์ฆ ์ค‘ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ๋Š” ์˜ˆ์™ธ์— ๋Œ€ํ•œ ์ฒ˜๋ฆฌ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค. ์ธ์ฆ ์ฝ”๋“œ ๊ฒ€์ฆ ์‹คํŒจ ์‹œ ์‚ฌ์šฉ์ž์—๊ฒŒ ์ ์ ˆํ•œ ํ”ผ๋“œ๋ฐฑ์„ ์ œ๊ณตํ•  ์ˆ˜ ์žˆ๋„๋ก ์˜ˆ์™ธ ์ฒ˜๋ฆฌ๋ฅผ ์ถ”๊ฐ€ํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotEmpty;

public record EmailRequestDto(
public record EmailRequest(
@NotEmpty(message = "์ด๋ฉ”์ผ ์ฃผ์†Œ๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.")
@Email(message = "์œ ํšจํ•˜์ง€ ์•Š์€ ์ด๋ฉ”์ผ ํ˜•์‹์ž…๋‹ˆ๋‹ค.")
String email
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.Pattern;

public record EmailVerificationRequestDto(
public record EmailVerificationRequest(
@NotEmpty(message = "์ด๋ฉ”์ผ ์ฃผ์†Œ๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.")
@Email(message = "์œ ํšจํ•˜์ง€ ์•Š์€ ์ด๋ฉ”์ผ ํ˜•์‹์ž…๋‹ˆ๋‹ค.")
String email,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;

public record LoginRequestDto(
public record LoginRequest(
@NotBlank(message = "์ด๋ฉ”์ผ์€ ํ•„์ˆ˜์ž…๋‹ˆ๋‹ค")
@Email(message = "์˜ฌ๋ฐ”๋ฅธ ์ด๋ฉ”์ผ ํ˜•์‹์ด ์•„๋‹™๋‹ˆ๋‹ค")
String email,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;

public record RegisterRequestDto(
public record RegisterRequest(
@NotBlank(message = "์ด๋ฉ”์ผ์€ ํ•„์ˆ˜์ž…๋‹ˆ๋‹ค")
@Email(message = "์˜ฌ๋ฐ”๋ฅธ ์ด๋ฉ”์ผ ํ˜•์‹์ด ์•„๋‹™๋‹ˆ๋‹ค")
String email,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.mycom.socket.auth.dto.response;

public record EmailVerificationResponse(
String message
) {
public static EmailVerificationResponse of(String message) {
return new EmailVerificationResponse(message);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.mycom.socket.auth.dto.response;

public record LoginResponse(
String email,
String nickname
) {
public static LoginResponse of(String email, String nickname) {
return new LoginResponse(email, nickname);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.mycom.socket.auth.dto.response;

public record RegisterResponse(
Long memberId,
String email,
String nickname,
String message
) {
public static RegisterResponse of(Long memberId, String email, String nickname) {
return new RegisterResponse(memberId, email, nickname, "ํšŒ์›๊ฐ€์ž…์ด ์™„๋ฃŒ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.");
}
}
41 changes: 24 additions & 17 deletions src/main/java/com/mycom/socket/auth/jwt/JWTFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
Expand All @@ -15,33 +16,25 @@

import java.io.IOException;

@Slf4j
@RequiredArgsConstructor
public class JWTFilter extends OncePerRequestFilter {

private final JWTProperties jwtProperties;
private final JWTUtil jwtUtil;
private final MemberDetailsService memberDetailsService;

@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException {

String token = resolveTokenFromCookie(request);

protected void doFilterInternal(HttpServletRequest request,
HttpServletResponse response,
FilterChain filterChain) throws ServletException, IOException {
try {
String token = resolveTokenFromCookie(request);
if (StringUtils.hasText(token) && jwtUtil.validateToken(token)) {
String email = jwtUtil.getEmail(token);
UserDetails userDetails = memberDetailsService.loadUserByUsername(email);

UsernamePasswordAuthenticationToken authentication =
new UsernamePasswordAuthenticationToken(
userDetails,
null,
userDetails.getAuthorities()
);

SecurityContextHolder.getContext().setAuthentication(authentication);
setAuthentication(token);
}
} catch (Exception e) {
log.warn("์ธ์ฆ ์ฒ˜๋ฆฌ ์‹คํŒจ", e);
SecurityContextHolder.clearContext();
}

Expand All @@ -52,11 +45,25 @@ private String resolveTokenFromCookie(HttpServletRequest request) {
Cookie[] cookies = request.getCookies();
if (cookies != null) {
for (Cookie cookie : cookies) {
if ("Authorization".equals(cookie.getName())) {
if (jwtProperties.getCookieName().equals(cookie.getName())) {
return cookie.getValue();
}
}
}
return null;
}

private void setAuthentication(String token) {
String email = jwtUtil.getEmail(token);
UserDetails userDetails = memberDetailsService.loadUserByUsername(email);

UsernamePasswordAuthenticationToken authentication =
new UsernamePasswordAuthenticationToken(
userDetails,
null,
userDetails.getAuthorities()
);

SecurityContextHolder.getContext().setAuthentication(authentication);
}
}
17 changes: 17 additions & 0 deletions src/main/java/com/mycom/socket/auth/jwt/JWTProperties.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.mycom.socket.auth.jwt;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Getter
@Setter
@Component
@ConfigurationProperties(prefix = "jwt")
public class JWTProperties {
private String secret;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

โš ๏ธ Potential issue

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.

Suggested change
private String secret;
@NotEmpty(message = "JWT secret์€ ํ•„์ˆ˜ ๊ฐ’์ž…๋‹ˆ๋‹ค.")
private String secret;

private long accessTokenValidityInSeconds = 1800;
Copy link

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.

Suggested change
private long accessTokenValidityInSeconds = 1800;
@Min(value = 300, message = "ํ† ํฐ ์œ ํšจ ๊ธฐ๊ฐ„์€ ์ตœ์†Œ 5๋ถ„ ์ด์ƒ์ด์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.")
private long accessTokenValidityInSeconds = 1800;

private String cookieName = "Authorization";
private String issuer = "go_socket";
private boolean secureCookie = false;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๐Ÿ’ก Codebase verification

โš ๏ธ Potential issue

๋ณด์•ˆ ์ฟ ํ‚ค ์„ค์ • ๋ฌธ์ œ ํ™•์ธ๋จ

ํ˜„์žฌ ๊ตฌ์„ฑ์—์„œ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์‹ฌ๊ฐํ•œ ๋ณด์•ˆ ๋ฌธ์ œ๊ฐ€ ํ™•์ธ๋˜์—ˆ์Šต๋‹ˆ๋‹ค:

  • 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

}
37 changes: 27 additions & 10 deletions src/main/java/com/mycom/socket/auth/jwt/JWTUtil.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package com.mycom.socket.auth.jwt;

import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.security.Keys;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

import javax.crypto.SecretKey;
import java.nio.charset.StandardCharsets;
Expand All @@ -16,42 +15,60 @@
public class JWTUtil {

private final SecretKey secretKey;
private final JWTProperties jwtProperties;

public JWTUtil(@Value("${jwt.secret}") String secret) {
this.secretKey = Keys.hmacShaKeyFor(secret.getBytes(StandardCharsets.UTF_8));
public JWTUtil(JWTProperties jwtProperties) {
this.jwtProperties = jwtProperties;
this.secretKey = Keys.hmacShaKeyFor(
jwtProperties.getSecret().getBytes(StandardCharsets.UTF_8)
);
}

/**
* JWT ํ† ํฐ ์ƒ์„ฑ
*/
public String createToken(String email) {
Claims claims = Jwts.claims().subject(email).build();
Date now = new Date();
// 30๋ถ„
long accessTokenValidityInMilliseconds = 1000 * 60 * 30;
Date validity = new Date(now.getTime() + accessTokenValidityInMilliseconds);
Date validity = new Date(now.getTime() +
(jwtProperties.getAccessTokenValidityInSeconds() * 1000));

return Jwts.builder()
.claims(claims)
.issuer(jwtProperties.getIssuer())
.subject(email)
.issuedAt(now)
.expiration(validity)
.signWith(secretKey)
.compact();
}

/**
* ํ† ํฐ ์œ ํšจ์„ฑ ๊ฒ€์ฆ
*/
public boolean validateToken(String token) {
try {
if (!StringUtils.hasText(token)) {
return false;
}

Jwts.parser()
.verifyWith(secretKey)
.requireIssuer(jwtProperties.getIssuer())
.build()
.parseSignedClaims(token);
return true;
} catch (Exception e) {
log.warn("JWT ํ† ํฐ ๊ฒ€์ฆ ์ค‘ ์—๋Ÿฌ ๋ฐœ์ƒ: {}", e.getMessage());
log.warn("JWT ํ† ํฐ ๊ฒ€์ฆ ์‹คํŒจ", e);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

โš ๏ธ Potential issue

์˜ˆ์™ธ ๋ฉ”์‹œ์ง€์— ๋ฏผ๊ฐํ•œ ์ •๋ณด๊ฐ€ ํฌํ•จ๋˜์ง€ ์•Š๋„๋ก ๋กœ๊ทธ๋ฅผ ๊ฐœ์„ ํ•˜์‹ญ์‹œ์˜ค.

validateToken ๋ฉ”์„œ๋“œ์—์„œ ์˜ˆ์™ธ ๋ฐœ์ƒ ์‹œ ์ „์ฒด ์˜ˆ์™ธ๋ฅผ ๋กœ๊ทธ์— ๊ธฐ๋กํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ์˜ˆ์™ธ ๋ฉ”์‹œ์ง€์— ๋ฏผ๊ฐํ•œ ์ •๋ณด๊ฐ€ ํฌํ•จ๋  ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ, ๋กœ๊ทธ์— ์˜ˆ์™ธ ๋ฉ”์‹œ์ง€๋ฅผ ํฌํ•จํ•˜์ง€ ์•Š๊ฑฐ๋‚˜ ์ตœ์†Œํ•œ์˜ ์ •๋ณด๋งŒ ๊ธฐ๋กํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.

return false;
}
}

/**
* ํ† ํฐ์—์„œ ์ด๋ฉ”์ผ ์ถ”์ถœ
*/
public String getEmail(String token) {
return Jwts.parser()
.verifyWith(secretKey)
.requireIssuer(jwtProperties.getIssuer())
.build()
.parseSignedClaims(token)
.getPayload()
Expand Down
Loading
Loading