Skip to content

Commit 66bada0

Browse files
committed
lab06 Custom 403(Access Denied Page)
1 parent bc95bbb commit 66bada0

5 files changed

Lines changed: 38 additions & 6 deletions

File tree

lab06_springboot2_sec_jpa_thymeleaf/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
## TODO
1919

20-
1. [ ] Custom 403(Access Denied Page)
20+
1. [x] Custom 403(Access Denied Page)
2121
2. [x] Remember me
2222
3. [ ] JWT
2323
4. [ ] Spinner

lab06_springboot2_sec_jpa_thymeleaf/course-app/src/main/java/me/cyper/fsd/lab06/config/SpringSecurityConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ protected void configure(HttpSecurity http) throws Exception {
8080
.requestMatchers(PathRequest.toStaticResources().atCommonLocations()).permitAll()
8181

8282
.antMatchers("/","/register", "/captcha_image**", "/h2/**").permitAll()
83-
.antMatchers("/admin/**").hasAnyRole("ADMIN")
84-
.antMatchers("/user/**").hasAnyRole("USER")
83+
.antMatchers("/admin/**").hasRole("ADMIN")
84+
.antMatchers("/user/**").hasRole("USER")
8585

8686
// every request requires the user to be authenticated
8787
.anyRequest().authenticated()
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!DOCTYPE HTML>
2+
<html lang="en" xmlns:th="http://www.thymeleaf.org">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>FSD Course Center</title>
6+
<script th:src="@{/webjars/jquery/3.4.1/dist/jquery.min.js}"></script>
7+
<script th:src="@{/webjars/bootstrap/4.3.1/js/bootstrap.min.js}"></script>
8+
<link rel="stylesheet" th:href="@{/webjars/bootstrap/4.3.1/css/bootstrap.min.css}" />
9+
<link rel="stylesheet" th:href="@{/css/layout.css}" />
10+
</head>
11+
<body>
12+
<div th:replace="fragments/header :: header"></div>
13+
14+
<div class="container-fluid">
15+
<div class="row flex-xl-nowrap">
16+
<div class="col-12 col-md-3 col-xl-2 bd-sidebar">
17+
<div th:replace="fragments/sidemenu :: search"></div>
18+
<div th:replace="fragments/sidemenu :: nav"></div>
19+
</div>
20+
21+
<main class="col-12 col-md-9 col-xl-10 py-md-3 pl-md-5 bd-content"
22+
role="main">
23+
<h3 class="text-secondary">Sorry! Access denied :(</h1>
24+
You don't have permission to view this page.
25+
</main>
26+
27+
28+
</div>
29+
30+
</div>
31+
</body>
32+
</html>

lab06_springboot2_sec_jpa_thymeleaf/course-app/src/main/resources/templates/home.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<title>FSD Course Center</title>
66
<script th:src="@{/webjars/jquery/3.4.1/dist/jquery.min.js}"></script>
77
<script th:src="@{/webjars/bootstrap/4.3.1/js/bootstrap.min.js}"></script>
8-
<link rel="stylesheet" th:href="@{webjars/bootstrap/4.3.1/css/bootstrap.min.css}" />
8+
<link rel="stylesheet" th:href="@{/webjars/bootstrap/4.3.1/css/bootstrap.min.css}" />
99
<link rel="stylesheet" th:href="@{/css/layout.css}" />
1010
</head>
1111
<body>

lab06_springboot2_sec_jpa_thymeleaf/course-app/src/main/resources/templates/login.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<meta charset="UTF-8">
55
<title>FSD Course Center - Login</title>
66
<script th:src="@{/webjars/jquery/3.4.1/dist/jquery.min.js}"></script>
7-
<link type="text/css" rel="stylesheet" th:href="@{webjars/font-awesome/5.9.0/css/all.css}" />
8-
<link type="text/css" rel="stylesheet" th:href="@{webjars/bootstrap/4.3.1/css/bootstrap.min.css}" />
7+
<link type="text/css" rel="stylesheet" th:href="@{/webjars/font-awesome/5.9.0/css/all.css}" />
8+
<link type="text/css" rel="stylesheet" th:href="@{/webjars/bootstrap/4.3.1/css/bootstrap.min.css}" />
99
<link type="text/css" rel="stylesheet" th:href="@{/css/signin.css}" />
1010
<script th:inline="javascript">
1111
function changeCaptcha(){

0 commit comments

Comments
 (0)