-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
hyun123
committed
Oct 14, 2024
1 parent
231b683
commit f1bc240
Showing
1 changed file
with
26 additions
and
14 deletions.
There are no files selected for viewing
40 changes: 26 additions & 14 deletions
40
src/main/java/kr/co/mcmp/config/WebSecurityConfigurer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,39 @@ | ||
package kr.co.mcmp.config; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; | ||
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.web.SecurityFilterChain; | ||
|
||
|
||
@Configuration | ||
@EnableWebSecurity | ||
@EnableGlobalMethodSecurity(prePostEnabled = true) | ||
public class WebSecurityConfigurer extends WebSecurityConfigurerAdapter { | ||
// @EnableGlobalMethodSecurity(prePostEnabled = true) | ||
public class WebSecurityConfigurer { | ||
|
||
|
||
@Override | ||
public void configure(WebSecurity webSecurity) throws Exception { | ||
webSecurity.ignoring().antMatchers("/resources/**", "/h2-console/**"); | ||
} | ||
// @Override | ||
// public void configure(WebSecurity webSecurity) throws Exception { | ||
// webSecurity.ignoring().antMatchers("/resources/**", "/h2-console/**"); | ||
// } | ||
|
||
@Override | ||
public void configure(HttpSecurity https) throws Exception { | ||
https.authorizeRequests().antMatchers("/**").permitAll(); | ||
https.csrf().disable(); | ||
} | ||
// @Override | ||
// public void configure(HttpSecurity https) throws Exception { | ||
// https.authorizeRequests().antMatchers("/**").permitAll(); | ||
// https.csrf().disable(); | ||
// } | ||
@Bean | ||
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { | ||
http | ||
.headers(headers -> headers | ||
.frameOptions().disable() // X-Frame-Options 비활성화 | ||
) | ||
.cors().and() | ||
.csrf().disable() | ||
.authorizeHttpRequests(authz -> authz | ||
.anyRequest().permitAll() | ||
); | ||
return http.build(); | ||
} | ||
} |