diff --git a/.gitignore b/.gitignore index c2065bc..0e0fa44 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,8 @@ bin/ !**/src/main/**/bin/ !**/src/test/**/bin/ +applicaion.properties + ### IntelliJ IDEA ### .idea *.iws diff --git a/src/main/java/com/vacation/platform/stayfinder/config/SecurityConfig.java b/src/main/java/com/vacation/platform/stayfinder/config/SecurityConfig.java new file mode 100644 index 0000000..3b7734d --- /dev/null +++ b/src/main/java/com/vacation/platform/stayfinder/config/SecurityConfig.java @@ -0,0 +1,36 @@ +package com.vacation.platform.stayfinder.config; + + +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.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; +import org.springframework.security.config.annotation.web.configurers.HeadersConfigurer; +import org.springframework.security.web.SecurityFilterChain; + +@Configuration +@EnableWebSecurity +public class SecurityConfig { + + @Bean + public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { + http + .csrf(AbstractHttpConfigurer::disable); + http + .headers((headerConfig) -> + headerConfig.frameOptions(HeadersConfigurer.FrameOptionsConfig::disable)); + + http + .authorizeHttpRequests((authorizationManagerRequestMatcherRegistry) -> + authorizationManagerRequestMatcherRegistry + .requestMatchers(PathRequest.toH2Console()).permitAll() +// .requestMatchers("**/**").permitAll() +// .anyRequest().authenticated() // 위에 패턴 이외에는 인증해야한다. + .anyRequest().permitAll() + ); + return http.build(); + } + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index cb73064..27be42f 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1 +1,9 @@ spring.application.name=stayfinder + + +spring.h2.console.path=/h2-console +spring.datasource.url=jdbc:h2:mem:testdb +spring.datasource.driver-class-name=org.h2.Driver +spring.datasource.username=sa +spring.datasource.password=123 +spring.h2.console.enabled=true \ No newline at end of file