-
Notifications
You must be signed in to change notification settings - Fork 0
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
Security 관련 코드 리팩토링 & 카카오 로그인 방식 제거 #20
Changes from all commits
3b2afee
1fb960a
958b229
4b6f188
894f8a6
400c818
792f070
cd22024
99142d6
63a5beb
cbace22
aef10b4
079c4b6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.zoopi.config; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
@Configuration | ||
public class ObjectMapperConfig { | ||
|
||
@Bean | ||
public ObjectMapper objectMapper() { | ||
return new ObjectMapper(); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.zoopi.config.security.exception; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.springframework.security.core.AuthenticationException; | ||
|
||
import com.zoopi.exception.response.ErrorCode; | ||
import com.zoopi.exception.response.ErrorResponse; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public abstract class CustomAuthenticationException extends AuthenticationException { | ||
|
||
private final ErrorCode errorCode; | ||
private final List<ErrorResponse.FieldError> errors; | ||
|
||
public CustomAuthenticationException(ErrorCode errorCode, List<ErrorResponse.FieldError> errors) { | ||
super(errorCode.getMessage()); | ||
this.errorCode = errorCode; | ||
this.errors = errors; | ||
} | ||
|
||
public CustomAuthenticationException(ErrorCode errorCode) { | ||
super(errorCode.getMessage()); | ||
this.errorCode = errorCode; | ||
this.errors = new ArrayList<>(); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,21 +2,18 @@ | |
|
||
import java.util.List; | ||
|
||
import org.springframework.security.core.AuthenticationException; | ||
|
||
import com.zoopi.config.security.exception.CustomAuthenticationException; | ||
import com.zoopi.exception.response.ErrorCode; | ||
import com.zoopi.exception.response.ErrorResponse; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public class JwtAuthenticationException extends AuthenticationException { | ||
public class JwtAuthenticationException extends CustomAuthenticationException { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이런식으로 인증쪽 관련된 별도의 클래스를 만들어 사용하는 것도 굉장히 깔끔하고 좋은 방법인 것 같네요 👍 다만, 제가 Spring Security 를 사용하면서 느낀 부분이 굉장히 Spring Security 의존적으로 개발하게 되는 것 같다는 것인데요, 제가 생각한 방법은 따로 Spring Security 에서 제공해주는 CustomAuthenticationEntryPoint, CustomAccessDeniedHandler 를 사용하지 않고, JwtAuthenticationFilter.unsuccessfulAuthentication() 메소드에서 BusinessException 을 상속한 별도의 Exception 으로 throw 하게 되면 에러 처리에 대한 포인트를 하나로 모을 수 있을것 같다는 생각이 문득 들어서요!! @seonpilKim @dongkyunkimdev 이 부분에 대해서 함께 논의해보고 싶습니다! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 엇 혹시 filter에서 발생한 예외도 Advice가 처리할 수 있을까요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 훔... 그렇군요!! 왜 된다고 생각했는지 모르겠는데 좀더 알아볼걸 그랬네요 ㅠ__ㅠ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 저도 개념, 기술적으로 모르거나 애매하게 아는 부분이 엄청 많아서, 이런 논의들을 하면서 모르는 것도 알아가고, 애매하게 아는 것은 더 확실하게 알게 되니까 되게 좋은 것 같습니다!! |
||
|
||
private final List<ErrorResponse.FieldError> errors; | ||
|
||
public JwtAuthenticationException(List<ErrorResponse.FieldError> errors) { | ||
super(ErrorCode.AUTHENTICATION_FAILURE.getMessage()); | ||
this.errors = errors; | ||
super(ErrorCode.AUTHENTICATION_FAILURE, errors); | ||
} | ||
|
||
} |
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.
👍