From 695908e2c775c12effe94ff8fd7db0a6840f179c Mon Sep 17 00:00:00 2001 From: kimyonghwa Date: Thu, 9 May 2019 14:07:27 +0900 Subject: [PATCH] bugfix : exception process --- .../rest/api/config/security/CustomAccessDeniedHandler.java | 3 +-- .../api/config/security/CustomAuthenticationEntryPoint.java | 3 +-- .../com/rest/api/config/security/SecurityConfiguration.java | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/rest/api/config/security/CustomAccessDeniedHandler.java b/src/main/java/com/rest/api/config/security/CustomAccessDeniedHandler.java index eaaa3cb..6a59be1 100644 --- a/src/main/java/com/rest/api/config/security/CustomAccessDeniedHandler.java +++ b/src/main/java/com/rest/api/config/security/CustomAccessDeniedHandler.java @@ -22,7 +22,6 @@ public class CustomAccessDeniedHandler implements AccessDeniedHandler { @Override public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException exception) throws IOException, ServletException { - RequestDispatcher dispatcher = request.getRequestDispatcher("/exception/accessdenied"); - dispatcher.forward(request, response); + response.sendRedirect("/exception/accessdenied"); } } diff --git a/src/main/java/com/rest/api/config/security/CustomAuthenticationEntryPoint.java b/src/main/java/com/rest/api/config/security/CustomAuthenticationEntryPoint.java index 35cce6b..5d96f7c 100644 --- a/src/main/java/com/rest/api/config/security/CustomAuthenticationEntryPoint.java +++ b/src/main/java/com/rest/api/config/security/CustomAuthenticationEntryPoint.java @@ -18,7 +18,6 @@ public class CustomAuthenticationEntryPoint implements AuthenticationEntryPoint @Override public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException ex) throws IOException, ServletException { - RequestDispatcher dispatcher = request.getRequestDispatcher("/exception/entrypoint"); - dispatcher.forward(request, response); + response.sendRedirect("/exception/entrypoint"); } } diff --git a/src/main/java/com/rest/api/config/security/SecurityConfiguration.java b/src/main/java/com/rest/api/config/security/SecurityConfiguration.java index 923854e..aaf5ba5 100644 --- a/src/main/java/com/rest/api/config/security/SecurityConfiguration.java +++ b/src/main/java/com/rest/api/config/security/SecurityConfiguration.java @@ -32,7 +32,7 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter { .and() .authorizeRequests() // 다음 리퀘스트에 대한 사용권한 체크 .antMatchers("/*/signin", "/*/signup").permitAll() // 가입 및 인증 주소는 누구나 접근가능 - .antMatchers(HttpMethod.GET, "/helloworld/**").permitAll() // hellowworld로 시작하는 GET요청 리소스는 누구나 접근가능 + .antMatchers(HttpMethod.GET, "/exception/**","/helloworld/**").permitAll() // hellowworld로 시작하는 GET요청 리소스는 누구나 접근가능 .antMatchers("/*/users").hasRole("ADMIN") .anyRequest().hasRole("USER") // 그외 나머지 요청은 모두 인증된 회원만 접근 가능 .and()