Tutorial 6
Tutorial 6
Contents:
Build JDBC-based login feature with Spring Security.
Instructions:
1. Create a Spring Boot project with the dependencies for a typical web app and Spring
Security:
Spring Web
Spring Data JPA
MySQL Driver or MariaDB Driver
Thymeleaf
Spring Security
Allow everyone to access all URLs except the ones in the /member directory,
which are only accessible for authenticated users.
Use the Form Login method to authenticate users. Use all default URLs for
login and logout.
Disable CSRF.
4. Create necessary tables (users and authorities) in your database to store users.
Refer to Lecture 6 for the SQL script to create these tables.
SE2 – TUTORIAL 6
.roles("USER")
.build();
JdbcUserDetailsManager users =
new JdbcUserDetailsManager(dataSource);
users.createUser(user);
return users;
}
@Bean
PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
SE2 – TUTORIAL 6