Skip to content

Commit 0bcbc81

Browse files
authored
Merge pull request #16 from codej99/feature/security
Feature/security
2 parents 5f1bd9f + 951bd95 commit 0bcbc81

File tree

3 files changed

+4
-8
lines changed

3 files changed

+4
-8
lines changed

‎src/main/java/com/rest/api/config/security/CustomAccessDeniedHandler.java

+2-6
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
import org.springframework.security.web.access.AccessDeniedHandler;
66
import org.springframework.stereotype.Component;
77

8-
import javax.servlet.RequestDispatcher;
9-
import javax.servlet.ServletException;
108
import javax.servlet.http.HttpServletRequest;
119
import javax.servlet.http.HttpServletResponse;
1210
import java.io.IOException;
@@ -16,9 +14,7 @@
1614
public class CustomAccessDeniedHandler implements AccessDeniedHandler {
1715

1816
@Override
19-
public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException exception) throws IOException,
20-
ServletException {
21-
RequestDispatcher dispatcher = request.getRequestDispatcher("/exception/accessdenied");
22-
dispatcher.forward(request, response);
17+
public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException exception) throws IOException {
18+
response.sendRedirect("/exception/accessdenied");
2319
}
2420
}

‎src/main/java/com/rest/api/config/security/CustomAuthenticationEntryPoint.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ public class CustomAuthenticationEntryPoint implements AuthenticationEntryPoint
1818
@Override
1919
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException ex) throws IOException,
2020
ServletException {
21-
RequestDispatcher dispatcher = request.getRequestDispatcher("/exception/entrypoint");
22-
dispatcher.forward(request, response);
21+
response.sendRedirect("/exception/entrypoint");
2322
}
2423
}

‎src/main/java/com/rest/api/config/security/SecurityConfiguration.java

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ protected void configure(HttpSecurity http) throws Exception {
3232
.and()
3333
.authorizeRequests() // 다음 리퀘스트에 대한 사용권한 체크
3434
.antMatchers("/*/signin", "/*/signin/**", "/*/signup", "/*/signup/**", "/social/**").permitAll() // 가입 및 인증 주소는 누구나 접근가능
35+
.antMatchers(HttpMethod.GET, "/exception/**","/helloworld/**").permitAll() // hellowworld로 시작하는 GET요청 리소스는 누구나 접근가능
3536
.antMatchers(HttpMethod.GET, "/helloworld/**","/actuator/health").permitAll() // hellowworld로 시작하는 GET요청 리소스는 누구나 접근가능
3637
.anyRequest().hasRole("USER") // 그외 나머지 요청은 모두 인증된 회원만 접근 가능
3738
.and()

0 commit comments

Comments
 (0)