728x90
@EnableWebSecurity
@Configuration
@AllArgsConstructor
public class SecurityConfig {
private final CustomUserServiceImp customUserServiceImp;
@Bean
public BCryptPasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http.authorizeHttpRequests(
(auth) ->
auth.antMatchers("/user/**", "/auth/**").permitAll().anyRequest().authenticated())
.httpBasic(withDefaults());
http.headers()
.frameOptions().sameOrigin();
http.userDetailsService(customUserServiceImp);
return http.build();
}
@Bean
public WebSecurityCustomizer webSecurityCustomizer() {
return (web -> web.ignoring().antMatchers("/images/**", "/js/**", "/webjars/**"));
}
}
내저장소 바로가기 luxury515
'Springboot3.0' 카테고리의 다른 글
[Interface]`UserDetailsService` (0) | 2023.04.16 |
---|---|
[Interface]`UserDetails` 구현 (0) | 2023.04.16 |