뭐든 즐기면서 ;)

Spring Security 기본 설정 본문

BACK/Spring Boot & JPA

Spring Security 기본 설정

Tada.*+ 2023. 4. 28. 20:31
728x90
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.configuration.EnableWebSecurity;
import org.springframework.security.web.SecurityFilterChain;

import static org.springframework.security.config.Customizer.withDefaults;

@Configuration
@EnableWebSecurity
public class SecurityConfig {

    @Bean
    public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
        http.authorizeHttpRequests((authz) -> authz
                /**
                 *  TODO
                 *  필요 시 'authenticated' 추가
                 *  */
                //.antMatchers("[/url]").authenticated()
                .anyRequest().permitAll()
                ).httpBasic(withDefaults());

        http.csrf().disable();
        return http.build();
    }
}
728x90
Comments