1.의의

2.접근 거부 미처리(ch0802)

http.authorizeRequests()
		.requestMatchers(PathRequest.toStaticResources().atCommonLocations()).access("permitAll")
		.antMatchers("/").access("permitAll")
		.antMatchers("/auth/login").access("permitAll")
		.antMatchers("/user/register", "/user/registerSuccess").access("permitAll")	
		.antMatchers("/codegroup/**").access("hasRole('ADMIN')")
		.antMatchers("/codedetail/**").access("hasRole('ADMIN')")
		.antMatchers("/board/list", "/board/read").access("permitAll")
		.antMatchers("/board/register", "/board/modify").access("hasRole('MEMBER')")
		.antMatchers("/board/remove").access("hasAnyRole('MEMBER', 'ADMIN')")
		.antMatchers("/notice/list", "/notice/read").access("permitAll")
		.antMatchers("/notice/register", "/notice/modify", "/notice/remove").access("hasRole('ADMIN')")
		.anyRequest().authenticated();

Untitled

Untitled

3.접근 거부 에러 페이지 URL를 지정(ch0802a)

http.authorizeRequests()
		.requestMatchers(PathRequest.toStaticResources().atCommonLocations()).access("permitAll")
		.antMatchers("/").access("permitAll")
		.antMatchers("/auth/login").access("permitAll")
		.antMatchers("/user/register", "/user/registerSuccess").access("permitAll")	
		.antMatchers("/codegroup/**").access("hasRole('ADMIN')")
		.antMatchers("/codedetail/**").access("hasRole('ADMIN')")
		.antMatchers("/board/list", "/board/read").access("permitAll")
		.antMatchers("/board/register", "/board/modify").access("hasRole('MEMBER')")
		.antMatchers("/board/remove").access("hasAnyRole('MEMBER', 'ADMIN')")
		.antMatchers("/notice/list", "/notice/read").access("permitAll")
		.antMatchers("/notice/register", "/notice/modify", "/notice/remove").access("hasRole('ADMIN')")
		.anyRequest().authenticated();
		
	
		
		http.exceptionHandling()
		.accessDeniedPage("/error/accessError");
<html xmlns:th="<http://www.thymeleaf.org>"
	xmlns:layout="<http://www.ultraq.net.nz/thymeleaf/layout>"
	layout:decorate="~{/layouts/common_template}">
  
<head>
	<title>Error</title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<link rel="stylesheet" href="../../static/css/style.css" th:href="@{/css/style.css}"/>	
</head>
<body>
	<div layout:fragment="content">
		<h2 th:text="#{common.error.accessDeniedPage}"></h2>
		
		<a href="javascript:window.history.back();" th:text="#{common.error.backPage}">이전페이지</a>
		<br />
		<a href="/" th:text="#{common.error.returnHome}">홈으로 돌아기기</a>
	</div>
</body>
</html>

Untitled

4.사용자 정의 접근 거부 처리자(ch0802_b)