mirror of
https://github.com/mrfluffy-dev/PRG381.git
synced 2026-01-17 02:10:33 +00:00
added admin page
This commit is contained in:
@@ -40,7 +40,9 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure(HttpSecurity http) throws Exception {
|
protected void configure(HttpSecurity http) throws Exception {
|
||||||
http.authorizeRequests().antMatchers(
|
http.authorizeRequests()
|
||||||
|
.antMatchers("/admin").hasRole("ADMIN")
|
||||||
|
.antMatchers(
|
||||||
"/registration**",
|
"/registration**",
|
||||||
"/js/**",
|
"/js/**",
|
||||||
"/css/**",
|
"/css/**",
|
||||||
@@ -57,6 +59,7 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
|
|||||||
.logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
|
.logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
|
||||||
.logoutSuccessUrl("/login?logout")
|
.logoutSuccessUrl("/login?logout")
|
||||||
.permitAll();
|
.permitAll();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,4 +15,9 @@ public class MainController {
|
|||||||
public String home() {
|
public String home() {
|
||||||
return "index";
|
return "index";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/admin")
|
||||||
|
public String admin() {
|
||||||
|
return "admin";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
45
src/main/resources/templates/admin.html
Normal file
45
src/main/resources/templates/admin.html
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns:th="http://www.thymeleaf.org"
|
||||||
|
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
|
||||||
|
<head>
|
||||||
|
<meta charset="ISO-8859-1">
|
||||||
|
<title>Registration and Login App</title>
|
||||||
|
|
||||||
|
<link rel="stylesheet"
|
||||||
|
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
|
||||||
|
integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
|
||||||
|
crossorigin="anonymous">
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<!-- create navigation bar ( header) -->
|
||||||
|
<nav class="navbar navbar-inverse navbar-fixed-top">
|
||||||
|
<div class="container">
|
||||||
|
<div class="navbar-header">
|
||||||
|
<button type="button" class="navbar-toggle collapsed"
|
||||||
|
data-toggle="collapse" data-target="#navbar" aria-expanded="false"
|
||||||
|
aria-controls="navbar">
|
||||||
|
<span class="sr-only">Toggle navigation</span> <span
|
||||||
|
class="icon-bar"></span> <span class="icon-bar"></span> <span
|
||||||
|
class="icon-bar"></span>
|
||||||
|
</button>
|
||||||
|
<a class="navbar-brand" href="#" th:href="@{/}">Registration and
|
||||||
|
Login Module</a>
|
||||||
|
</div>
|
||||||
|
<div id="navbar" class="collapse navbar-collapse">
|
||||||
|
<ul class="nav navbar-nav">
|
||||||
|
<li sec:authorize="isAuthenticated()"><a th:href="@{/logout}">Logout</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<h1>The good shit</h1>
|
||||||
|
Welcome <span sec:authentication="principal.username"> Admin</span>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -41,6 +41,8 @@
|
|||||||
<h1>Registration and Login with Spring Boot, Spring Security,
|
<h1>Registration and Login with Spring Boot, Spring Security,
|
||||||
Thymeleaf, Hibernate and MySQL</h1>
|
Thymeleaf, Hibernate and MySQL</h1>
|
||||||
Welcome <span sec:authentication="principal.username"> User</span>
|
Welcome <span sec:authentication="principal.username"> User</span>
|
||||||
|
<button type="button" class="btn btn-primary"
|
||||||
|
th:href="@{/admin}">admin</button>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -41,6 +41,8 @@
|
|||||||
<h1>Registration and Login with Spring Boot, Spring Security,
|
<h1>Registration and Login with Spring Boot, Spring Security,
|
||||||
Thymeleaf, Hibernate and MySQL</h1>
|
Thymeleaf, Hibernate and MySQL</h1>
|
||||||
Welcome <span sec:authentication="principal.username"> User</span>
|
Welcome <span sec:authentication="principal.username"> User</span>
|
||||||
|
<button type="button" class="btn btn-primary"
|
||||||
|
th:href="@{/admin}">admin</button>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user