Spring Boot 수강신청 웹 사이트 토이 프로젝트
- Java: JDK 11.0.13
- Spring Boot 2.6.4
- Gradle
- DB: H2 1.4.200 & MariaDB(AWS RDS) 10.5.13
- Cloud: AWS EC2
- CI/CD: TravisCI, AWS S3, AWS CodeDeploy
Spring Security 적용
@RequiredArgsConstructor
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
private final UserDetailsServiceImpl userDetailsService;
private final AuthSuccessHandler authSuccessHandler;
private final AuthFailureHandler authFailureHandler;
@Bean
public BCryptPasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable()
.authorizeRequests()
.antMatchers("/", "/home", "/login/**", "/css/**", "/signup/**").permitAll()
.anyRequest()
.authenticated()
.and()
.formLogin()
.usernameParameter("loginId")
.passwordParameter("password")
.loginPage("/login")
.loginProcessingUrl("/login/action")
.successHandler(authSuccessHandler)
.failureHandler(authFailureHandler)
.and()
.logout()
.logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
.logoutSuccessUrl("/home")
.invalidateHttpSession(true)
.deleteCookies("JSESSIONID").permitAll()
.and()
.sessionManagement()
.maximumSessions(1)
.maxSessionsPreventsLogin(false)
.expiredUrl("/login?error=true&exception=Session Expired!");
}
}
git clone https://github.com/wadekang/course-registration-system.git
# file_path: /src/main/resources/application-db.yml
spring:
datasource:
url: [DB URL]
username: [DB ID]
password: [DB Password]
driver-class-name: [DB Driver]
jpa:
hibernate:
ddl-auto: [ddl-auto] # create, update, none, create-drop
properties:
hibernate:
format_sql: true
dialect: org.hibernate.dialect.MySQL5InnoDBDialect
storage-engine: innodb