Skip to content

Commit

Permalink
Merge pull request #19 from Guzzing/auth
Browse files Browse the repository at this point in the history
Auth
  • Loading branch information
byeolhaha authored Nov 3, 2023
2 parents 9b1af00 + f4dc258 commit 236edf1
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;

import org.springframework.security.config.annotation.web.configurers.HttpBasicConfigurer;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.CorsConfigurationSource;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;

import java.util.Arrays;
import java.util.stream.Stream;



@Configuration
@EnableWebSecurity
public class SecurityConfig {
Expand All @@ -38,6 +48,7 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
)
.permitAll()
.anyRequest().authenticated())
.cors(cors -> cors.disable())
.sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
.csrf(AbstractHttpConfigurer::disable)
.httpBasic(HttpBasicConfigurer::disable)
Expand All @@ -47,4 +58,14 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
return http.build();
}

@Bean
CorsConfigurationSource corsConfigurationSource() {
CorsConfiguration configuration = new CorsConfiguration();
configuration.setAllowedOrigins(Arrays.asList("*"));
configuration.setAllowedMethods(Arrays.asList("*"));
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", configuration);
return source;
}

}

0 comments on commit 236edf1

Please sign in to comment.