Skip to content

Commit

Permalink
Merge pull request #62 from Catch-You/fix/사건상세조회
Browse files Browse the repository at this point in the history
[REFACTOR] corsConfig 적용
  • Loading branch information
xloyeon authored Dec 18, 2023
2 parents b78a784 + 0d5a98f commit 75914df
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class CorsConfig implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
ArrayList<String> allowedOriginPatterns = new ArrayList<>();
allowedOriginPatterns.add("http://localhost:3000");
allowedOriginPatterns.add("http://localhost:5173");
/*
Todo: 도메인 나오면 추가예정
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.security.access.hierarchicalroles.RoleHierarchy;
import org.springframework.security.access.hierarchicalroles.RoleHierarchyImpl;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration;
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.configuration.WebSecurityCustomizer;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.config.annotation.web.configurers.CorsConfigurer;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
Expand All @@ -37,6 +40,7 @@
@Configuration
public class SecurityConfig {
private final FilterConfig filterConfig;
private final CorsConfig corsConfig;

@Bean
public PasswordEncoder passwordEncoder() {
Expand All @@ -47,7 +51,7 @@ public PasswordEncoder passwordEncoder() {
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http
.csrf(AbstractHttpConfigurer::disable)
.cors(AbstractHttpConfigurer::disable)
.cors((Customizer<CorsConfigurer<HttpSecurity>>) corsConfig)
.formLogin(AbstractHttpConfigurer::disable)
.httpBasic(AbstractHttpConfigurer::disable)
.headers(AbstractHttpConfigurer::disable)
Expand All @@ -57,8 +61,6 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {

http.authorizeHttpRequests((authorizeRequests) ->
authorizeRequests
.requestMatchers(new AntPathRequestMatcher("/**/wfuchs.de/**"))
.denyAll()
.requestMatchers(
new AntPathRequestMatcher(API_PREFIX + "/auth/login"),
new AntPathRequestMatcher(API_PREFIX + "/signup/**"),
Expand Down

0 comments on commit 75914df

Please sign in to comment.