Added comments to web security confit, added registration pages to whitelist.

This commit is contained in:
Andrew Lalis 2019-05-29 13:32:37 +02:00 committed by andrewlalis
parent 153df56a89
commit 2805bb061e
4 changed files with 59 additions and 9 deletions

View File

@ -10,6 +10,15 @@ import org.springframework.security.config.annotation.web.configuration.WebSecur
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.crypto.password.PasswordEncoder;
/**
* Security configuration for the TAA application.
*
* This configuration makes use of the custom user details service provided by the application for database-persistent
* user accounts.
*
* Login, logout, and registration pages are set so that all users, authenticated and unauthenticated, may access them,
* while actual site content is only visible to authenticated users.
*/
@Configuration @Configuration
@EnableWebSecurity @EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter { public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@ -31,8 +40,8 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
http http
.csrf().disable() // So that we can GET the logout page. .csrf().disable() // So that we can GET the logout page.
.authorizeRequests() // Let anyone view the login and logout pages. .authorizeRequests() // Let anyone view the login and logout pages, as well as various registration pages.
.antMatchers("/login*", "/logout*", "/register*") .antMatchers("/login*", "/logout*", "/register*", "/register/**")
.permitAll() .permitAll()
.and() .and()

View File

@ -15,8 +15,6 @@ public class LoginController {
@GetMapping("/login") @GetMapping("/login")
public String get() { public String get() {
logger.info("User got login page.");
return "login"; return "login";
} }
} }

View File

@ -0,0 +1,19 @@
package nl.andrewlalis.teaching_assistant_assistant.controllers.register;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
/**
* Controller for the registration form for new students.
*/
@Controller
public class StudentRegisterController {
@GetMapping("/register/student")
public String get() {
return "/register/student";
}
}

View File

@ -1,10 +1,34 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html xmlns:th="http://www.thymeleaf.org" th:replace="~{layouts/basic_page :: layout (title='Register as a New Student', content=~{::#content})}" lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body> <body>
<section id="content" class="container">
<div class="row">
<div class="col">
<p>
Here you can register to create a new account to access the information provided by this application, whether you are a professor, teaching assistant, or student. After filling out this submission form, you'll receive an email with a link to verify that you are who you say you are, after which your account will be activated.
</p>
</div>
</div>
<div class="row justify-content-center">
<h3>I am a ...</h3>
</div>
<div class="row justify-content-center">
<div class="col text-center">
<a class="btn btn-primary" th:href="@{/register/student}">Student</a>
</div>
<div class="col text-center">
<a class="btn btn-primary" th:href="@{/register/teaching_assistant}">Teaching Assistant</a>
</div>
<div class="col text-center">
<a class="btn btn-primary" th:href="@{/register/administrator}">Administrator</a>
</div>
</div>
</section>
</body> </body>
</html> </html>