Skip to content

Commit

Permalink
Merge pull request #53 from cathaaaaand/dev
Browse files Browse the repository at this point in the history
ใ…‹
  • Loading branch information
EUNCHAEv1006 authored Apr 20, 2024
2 parents b4b500a + 5a27a31 commit a59bdf9
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.web.cors.CorsConfiguration;

import java.util.List;

@Configuration
@RequiredArgsConstructor
Expand All @@ -36,14 +39,10 @@ public JwtAuthorizationFilter jwtAuthorizationFilter() {

@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
// CSRF ์„ค์ •
http.csrf(AbstractHttpConfigurer::disable);

// ๊ธฐ๋ณธ ์„ค์ •์ธ Session ๋ฐฉ์‹์€ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ  JWT ๋ฐฉ์‹์„ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•œ ์„ค์ •
http.sessionManagement((sessionManagement) ->
sessionManagement.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
);

http.authorizeHttpRequests((authorizeHttpRequests) ->
authorizeHttpRequests
.requestMatchers(String.valueOf(PathRequest.toStaticResources().atCommonLocations()))
Expand All @@ -52,14 +51,16 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
.requestMatchers("/api/auth/**").permitAll()
.requestMatchers("/api/openAPI/**").permitAll()
.requestMatchers("/aws").permitAll()
.requestMatchers("/https://port-0-woori-forei-be-2aat2llv837pcn.sel5.cloudtype.app/").permitAll()
.anyRequest().authenticated()
);


// ํ•„ํ„ฐ ์ฒ˜๋ฆฌ
http.addFilterBefore(jwtAuthorizationFilter(), UsernamePasswordAuthenticationFilter.class);

http.cors().configurationSource(request -> {
CorsConfiguration cors = new CorsConfiguration();
cors.setAllowedOrigins(List.of("*"));
cors.setAllowedMethods(List.of("GET", "POST", "PUT", "DELETE", "OPTIONS"));
cors.setAllowedHeaders(List.of("*"));
return cors;
});
return http.build();
}
}

0 comments on commit a59bdf9

Please sign in to comment.