package com.ns.mobile.website.config; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.builders.WebSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.web.util.matcher.AntPathRequestMatcher; @Slf4j @Configuration @RequiredArgsConstructor @EnableWebSecurity public class SecurityConfiguration extends WebSecurityConfigurerAdapter { @Bean public PasswordEncoder getPasswordEncoder() { return new BCryptPasswordEncoder(); } @Override public void configure(WebSecurity web) throws Exception { web.ignoring().antMatchers("/favicon.ico" , "/apple-touch-icon.png" , "/res/**"); super.configure(web); } @Override protected void configure(HttpSecurity http) throws Exception { http.csrf().disable(); http.headers().frameOptions().sameOrigin(); http.authorizeRequests() .antMatchers("/", "/**") .permitAll(); /* http.logout() .logoutRequestMatcher(new AntPathRequestMatcher("/home/user/logout")) .logoutSuccessUrl("/") .invalidateHttpSession(true); */ http.exceptionHandling() .accessDeniedPage("/common/denied"); super.configure(http); } }