demo-decoupled docker-compose
This commit is contained in:
@@ -101,7 +101,9 @@ public class WebSecurityConfig {// extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Bean
|
||||
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
||||
http.csrf(csrf -> csrf.disable())
|
||||
http
|
||||
.cors(cors -> cors.configurationSource(corsConfigurationSource())) // Включаем CORS
|
||||
.csrf(csrf -> csrf.disable())
|
||||
.exceptionHandling(exception -> exception.authenticationEntryPoint(unauthorizedHandler))
|
||||
.sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
|
||||
.authorizeHttpRequests(auth ->
|
||||
@@ -126,4 +128,19 @@ public class WebSecurityConfig {// extends WebSecurityConfigurerAdapter {
|
||||
|
||||
return http.build();
|
||||
}
|
||||
|
||||
// Добавляем метод конфигурации CORS источников и разрешенных методов
|
||||
@Bean
|
||||
public org.springframework.web.cors.CorsConfigurationSource corsConfigurationSource() {
|
||||
org.springframework.web.cors.CorsConfiguration configuration = new org.springframework.web.cors.CorsConfiguration();
|
||||
// Укажите порты, с которых разрешено ходить (например, ваш Angular на 8081 и дефолтный 4200)
|
||||
configuration.setAllowedOrigins(java.util.List.of("http://localhost:8081", "http://localhost:4200", "http://localhost"));
|
||||
configuration.setAllowedMethods(java.util.List.of("GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH"));
|
||||
configuration.setAllowedHeaders(java.util.List.of("*"));
|
||||
configuration.setAllowCredentials(true);
|
||||
|
||||
org.springframework.web.cors.UrlBasedCorsConfigurationSource source = new org.springframework.web.cors.UrlBasedCorsConfigurationSource();
|
||||
source.registerCorsConfiguration("/**", configuration);
|
||||
return source;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
spring:
|
||||
application:
|
||||
name: demo-deoupled
|
||||
name: demo-decoupled
|
||||
datasource:
|
||||
url: jdbc:postgresql://localhost:5432/springangulardb
|
||||
url: jdbc:postgresql://jambo-postgres:5432/springangulardb
|
||||
username: springangular_user
|
||||
password: postgrespw
|
||||
flyway:
|
||||
enabled: true
|
||||
baseline-on-migrate: true
|
||||
url: jdbc:postgresql://localhost:5432/springangulardb?options=-c%20timezone=UTC
|
||||
url: jdbc:postgresql://jambo-postgres:5432/springangulardb?options=-c%20timezone=UTC
|
||||
user: springangular_user
|
||||
password: postgrespw
|
||||
jpa:
|
||||
|
||||
Reference in New Issue
Block a user