Compare commits

..

2 Commits

Author SHA1 Message Date
b79068623f Update jenkinsfile 2025-12-05 14:27:59 +00:00
Vincent Guillet
3eed3d251f Refactor CORS configuration to use allowed origins and enhance header handling 2025-12-05 15:14:16 +01:00
2 changed files with 35 additions and 21 deletions

View File

@@ -61,17 +61,26 @@ public class SecurityConfig {
@Bean @Bean
public CorsConfigurationSource corsConfigurationSource() { public CorsConfigurationSource corsConfigurationSource() {
CorsConfiguration config = new CorsConfiguration(); CorsConfiguration config = new CorsConfiguration();
config.setAllowedOriginPatterns(Arrays.asList(
"http://localhost:4200", // IMPORTANT : origins explicites, sans path
"http://127.0.0.1:4200", config.setAllowedOrigins(Arrays.asList(
"https://dev.vincent-guillet.fr", "http://localhost:4200",
"https://projets.vincent-guillet.fr" "http://127.0.0.1:4200",
)); "https://dev.vincent-guillet.fr",
config.setAllowedMethods(Arrays.asList("GET","POST","PUT","DELETE","OPTIONS")); "https://projets.vincent-guillet.fr"
config.setAllowedHeaders(Arrays.asList("Authorization","Content-Type","Accept")); ));
config.setExposedHeaders(Arrays.asList("Authorization"));
config.setAllowCredentials(true); config.setAllowCredentials(true);
// Autoriser tous les headers côté requête (plus robuste)
config.setAllowedHeaders(Arrays.asList("*"));
// Autoriser les méthodes classiques
config.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE", "OPTIONS"));
// Headers que le client *voit* dans la réponse
config.setExposedHeaders(Arrays.asList("Authorization", "Content-Type"));
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", config); source.registerCorsConfiguration("/**", config);
return source; return source;

View File

@@ -2,12 +2,12 @@ pipeline {
agent none agent none
environment { environment {
REGISTRY = 'registry.vincent-guillet.fr' REGISTRY = 'registry.vincent-guillet.fr'
API_IMAGE_DEV = "${REGISTRY}/gameovergne-api:dev-latest" API_IMAGE_DEV = "${REGISTRY}/gameovergne-api:dev-latest"
CLIENT_IMAGE_DEV= "${REGISTRY}/gameovergne-client:dev-latest" CLIENT_IMAGE_DEV = "${REGISTRY}/gameovergne-client:dev-latest"
API_IMAGE_PROD = "${REGISTRY}/gameovergne-api:prod-latest" API_IMAGE_PROD = "${REGISTRY}/gameovergne-api:prod-latest"
CLIENT_IMAGE_PROD = "${REGISTRY}/gameovergne-client:prod-latest" CLIENT_IMAGE_PROD = "${REGISTRY}/gameovergne-client:prod-latest"
COMPOSE_PROJECT = 'gameovergne-app' COMPOSE_PROJECT = 'gameovergne-app'
} }
stages { stages {
@@ -48,7 +48,6 @@ pipeline {
} }
// ----- Push vers registry ----- // ----- Push vers registry -----
// Si tu as des credentials, tu peux les utiliser ici via withCredentials
sh """ sh """
echo "=== Push images vers ${REGISTRY} ===" echo "=== Push images vers ${REGISTRY} ==="
docker push ${API_IMAGE} docker push ${API_IMAGE}
@@ -78,8 +77,11 @@ pipeline {
echo "=== [DEV] docker compose down ===" echo "=== [DEV] docker compose down ==="
docker compose -f docker-compose.dev.yml down -v || true docker compose -f docker-compose.dev.yml down -v || true
echo "=== [DEV] docker compose up ===" echo "=== [DEV] docker compose pull ==="
docker compose -f docker-compose.dev.yml up -d mysql spring angular docker compose -f docker-compose.dev.yml pull
echo "=== [DEV] docker compose up (force recreate) ==="
docker compose -f docker-compose.dev.yml up -d --force-recreate mysql spring angular
""" """
} }
} }
@@ -104,10 +106,13 @@ pipeline {
docker rm -f gameovergne-api-prod gameovergne-client-prod 2>/dev/null || true docker rm -f gameovergne-api-prod gameovergne-client-prod 2>/dev/null || true
echo "=== [PROD] docker compose down ===" echo "=== [PROD] docker compose down ==="
docker compose -f docker-compose.prod.yml down -v || true docker compose -f docker-compose.prod.yml down || true
echo "=== [PROD] docker compose up ===" echo "=== [PROD] docker compose pull ==="
docker compose -f docker-compose.prod.yml up -d mysql spring angular docker compose -f docker-compose.prod.yml pull
echo "=== [PROD] docker compose up (force recreate) ==="
docker compose -f docker-compose.prod.yml up -d --force-recreate mysql spring angular
""" """
} }
} }