-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat: Spring Security Filter 단에서 에러 처리하는 필터 및 로직 추가 * feat: Access Token, Refresh Token 각각 만료될 시에 에러 반환하는 메서드 구현 * chore: 토큰 만료 테스트를 위해 만료시간 짧게 설정 * feat: 이메일 중복 체크 메서드 구현 * fix: 예외 추가 * add: CD 위해 SecurityConfig 권한 허용 path 추가
- Loading branch information
Showing
15 changed files
with
161 additions
and
22 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
15 changes: 15 additions & 0 deletions
15
src/main/java/org/sophy/sophy/controller/TestController.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.sophy.sophy.controller; | ||
|
||
import org.sophy.sophy.common.dto.ApiResponseDto; | ||
import org.sophy.sophy.exception.SuccessStatus; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
public class TestController { | ||
|
||
@GetMapping("/test") | ||
public ApiResponseDto<String> test() { | ||
return ApiResponseDto.success(SuccessStatus.TEST_SUCCESS, SuccessStatus.TEST_SUCCESS.getMessage()); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/org/sophy/sophy/controller/dto/request/DuplCheckDto.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.sophy.sophy.controller.dto.request; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import javax.validation.constraints.Email; | ||
import javax.validation.constraints.NotNull; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class DuplCheckDto { | ||
@Email(message = "이메일 형식에 맞지 않습니다.") | ||
@NotNull | ||
String email; | ||
} |
This file contains 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
This file contains 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
10 changes: 10 additions & 0 deletions
10
src/main/java/org/sophy/sophy/exception/model/ExistEmailException.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.sophy.sophy.exception.model; | ||
|
||
import org.sophy.sophy.exception.ErrorStatus; | ||
|
||
public class ExistEmailException extends SophyException { | ||
|
||
public ExistEmailException(ErrorStatus errorStatus, String message) { | ||
super(errorStatus, message); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/org/sophy/sophy/exception/model/ExpiredRefreshTokenException.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.sophy.sophy.exception.model; | ||
|
||
import org.sophy.sophy.exception.ErrorStatus; | ||
|
||
public class ExpiredRefreshTokenException extends SophyException { | ||
|
||
public ExpiredRefreshTokenException(ErrorStatus errorStatus, String message) { | ||
super(errorStatus, message); | ||
} | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.sophy.sophy.jwt; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import io.jsonwebtoken.JwtException; | ||
import org.sophy.sophy.common.dto.ApiResponseDto; | ||
import org.sophy.sophy.exception.ErrorStatus; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.filter.OncePerRequestFilter; | ||
|
||
import javax.servlet.FilterChain; | ||
import javax.servlet.ServletException; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import java.io.IOException; | ||
|
||
@Component | ||
public class JwtExceptionFilter extends OncePerRequestFilter { | ||
|
||
@Autowired | ||
private ObjectMapper objectMapper; | ||
|
||
@Override | ||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { | ||
try { | ||
filterChain.doFilter(request, response); | ||
} catch (JwtException exception) { | ||
setErrorResponse(HttpStatus.UNAUTHORIZED, response, exception); | ||
} | ||
} | ||
|
||
public void setErrorResponse(HttpStatus status, HttpServletResponse res, Throwable ex) throws IOException { | ||
res.setStatus(status.value()); | ||
res.setContentType("application/json; charset=UTF-8"); | ||
|
||
res.getWriter().write(objectMapper.writeValueAsString(ApiResponseDto.error(ErrorStatus.INVALID_ACCESS_TOKEN_EXCEPTION, ex.getMessage()))); | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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