You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
AuthenticationInterceptor를 PathMatcherInterceptor로 감싸서, 인증 요청이 필요한 url과 요청을 묶어서 간결하게 처리할 수 있도록 개선했습니다.
if (authenticationRequestMatcher.isRequiredAuth(request)) {
//...
}
따라서 기존의 AuthenticationInterceptor에서 인증이 필요한 로직인지 판별했던 로직을 제거하였고,
PathMatcherInterceptor에서 인증이 필요한 요청을 판단한 후, 인증이 필요하다면 AuthenticationInterceptor의 preHandle 메서드를 호출하도록 개선했습니다.
AS-IS
preflight를 확인하는 로직이 AuthenticationInterceptor에 존재하고 있었습니다.
@Override
public boolean preHandle(final HttpServletRequest request, final HttpServletResponse response, final Object handler) {
if (isPreflight(request)) {
return true;
}
if (authenticationRequestMatcher.isRequiredAuth(request)) {
final String token = AuthenticationExtractor.extract(request);
validateToken(token, request.getRequestURI());
request.setAttribute("payload", token);
}
return true;
}
TO-BE
AuthenticationInterceptor.class
@Override
public boolean preHandle(final HttpServletRequest request, final HttpServletResponse response, final Object handler) {
final String token = AuthenticationExtractor.extract(request);
validateToken(token, request.getRequestURI());
request.setAttribute("payload", token);
return true;
}
PathMatcherInterceptor.class
@Override
public boolean preHandle(final HttpServletRequest request, final HttpServletResponse response, final Object handler)
throws Exception {
if (pathMatcherContainer.isNotIncludePath(request.getRequestURI(), request.getMethod())) {
return true;
}
return this.handlerInterceptor.preHandle(request, response, handler);
}
AuthenticationInterceptor은 검증을 하는 역할만 수행하도록 하고, PathMatcherInterceptor에서 preflight 요청 확인 및 인증이 필요한 경우 AuthenticationInterceptor를 호출하도록 개선했습니다.
The text was updated successfully, but these errors were encountered:
요약
현재 문제점
요약
세부사항
개선 사항
AS-IS
→ 따라서 많은 (인증)요청 url들을 텍스트로 관리하다 보니, 구현 및 테스트를 작성하는 과정에서 실수하는 일이 늘어났습니다.
TO-BE
AuthenticationInterceptor를 PathMatcherInterceptor로 감싸서, 인증 요청이 필요한 url과 요청을 묶어서 간결하게 처리할 수 있도록 개선했습니다.
따라서 기존의 AuthenticationInterceptor에서 인증이 필요한 로직인지 판별했던 로직을 제거하였고,
PathMatcherInterceptor에서 인증이 필요한 요청을 판단한 후, 인증이 필요하다면 AuthenticationInterceptor의 preHandle 메서드를 호출하도록 개선했습니다.
AS-IS
TO-BE
AuthenticationInterceptor.class
PathMatcherInterceptor.class
AuthenticationInterceptor은 검증을 하는 역할만 수행하도록 하고, PathMatcherInterceptor에서 preflight 요청 확인 및 인증이 필요한 경우 AuthenticationInterceptor를 호출하도록 개선했습니다.
The text was updated successfully, but these errors were encountered: