728x90
WebSecurityConfig.java
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/", "/페이지1", "/페이지12").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.permitAll()
.and()
.logout()
.logoutSuccessUrl("/페이지1")
.permitAll();
}
@Bean
public PasswordEncoder passwordEncoder() {
return PasswordEncoderFactories.createDelegatingPasswordEncoder();
}
}
WebSecurityConfig
MvcConfig.java
@Configuration
public class MvcConfig implements WebMvcConfigurer {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/테스트1").setViewName("테스트1");
registry.addViewController("/").setViewName("home");
registry.addViewController("/테스트2").setViewName("테스트2");
registry.addViewController("/login").setViewName("login");
}
}
728x90
'Web > tip' 카테고리의 다른 글
[Spring Boot] 강의 들으면서 쫌쫌따리 (0) | 2023.04.14 |
---|---|
[Spring Boot] 강의 들으면서 쫌쫌따리 (0) | 2023.04.14 |
[JPA] 강의 들으면서 쫌쫌따리 (0) | 2023.04.04 |
[Spring] JAR / WAR (0) | 2023.03.19 |
[error] Spring Boot jUnit Test : JPA metamodel must not be empty! (0) | 2023.03.18 |