package com.dbnt.kcgfilemanager.config; import com.dbnt.kcgfilemanager.userInfo.service.UserInfoService; import lombok.RequiredArgsConstructor; import org.springframework.boot.autoconfigure.security.servlet.PathRequest; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; 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.config.http.SessionCreationPolicy; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.crypto.password.Pbkdf2PasswordEncoder; import org.springframework.security.web.util.matcher.AntPathRequestMatcher; @RequiredArgsConstructor @EnableWebSecurity @Configuration public class WebSecurityConfig extends WebSecurityConfigurerAdapter { private final UserInfoService userInfoService; @Bean public PasswordEncoder passwordEncoder(){ return new Pbkdf2PasswordEncoder(); } @Override public void configure(WebSecurity web){ web.ignoring().requestMatchers(PathRequest.toStaticResources().atCommonLocations()); } @Override protected void configure(HttpSecurity http) throws Exception{ http.csrf().disable().authorizeRequests() .anyRequest().permitAll() .and() .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS) .and() .formLogin().disable(); // http.authorizeRequests() // .antMatchers("/login", "/signup", "/user").permitAll() // .anyRequest().authenticated() // 나머지 요청들은 권한의 종류에 상관 없이 권한이 있어야 접근 가능 // .and() // .formLogin() // .loginPage("/login") // .defaultSuccessUrl("/") // .and() // .logout() // .logoutRequestMatcher(new AntPathRequestMatcher("/logout")) // .logoutSuccessUrl("/login") // .invalidateHttpSession(true) // .and() // .exceptionHandling(); } // @Override // protected void configure(AuthenticationManagerBuilder auth) throws Exception{ // auth.userDetailsService(userInfoService).passwordEncoder(passwordEncoder()); // } }