Skip to content
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

[FEAT]: Security Filter 단 예외 핸들링 (JWT) #63

Merged
merged 5 commits into from
Aug 5, 2023
Merged

Conversation

jihwan2da
Copy link
Member

Issue number

  • resolved #0

작업 사항

  • Security Filter 단의 예외 핸들링 작업을 하였습니다.
  • JwtAuthenticationFilter 앞에 JwtExceptionHandleFilter를 두어서 예외 핸들링을 하였습니다.
  • AuthenticationEntryPoint를 사용하려고 했으나, Filter 단에서 예외 발생후 EntryPoint 단에 AuthenticationException이 넘어올 때 원하는 Exception이 넘어 오지 않고 InsufficientException이 넘어와서 JwtExceptionHandleFilter를 활용하였습니다. ( 이를 해결하려면 조금 시간이 걸릴 것 같애서 위 방법으로 대체하였습니다.)

@@ -7,20 +7,20 @@

@Getter
public class ErrorResponse {
private final LocalDateTime timestamp;
private final String timestamp;
Copy link
Member Author

Choose a reason for hiding this comment

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

ObjectMapper를 활용하여 Json 형태로 변환할 때 LocalDateTime을 지원하지 않아서 아래와 같이 ObjectMapper 설정을 통해 해결할 수 있었지만 Json 형태가 원하는 형태가 아니었기 때문에 String 타입으로 변경하였습니다.

objectMapper.registerModule(new JavaTimeModule());

Copy link
Member

@twoosky twoosky Aug 5, 2023

Choose a reason for hiding this comment

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

.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);

WRITE_DATES_AS_TIMESTAMPS 설정을 통해 JSON에서 날짜를 문자열로 표시할 수 있습니다!

@jihwan2da jihwan2da changed the title [FEAT]: Security 예외 핸들링 (JWT) [FEAT]: Security Filter 단 예외 핸들링 (JWT) Aug 5, 2023
@jihwan2da jihwan2da self-assigned this Aug 5, 2023
@jihwan2da jihwan2da merged commit 3cbdc3d into dev Aug 5, 2023
1 check passed
@jihwan2da jihwan2da deleted the fix/auth branch August 30, 2023 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants