Compare commits

..

4 Commits

Author SHA1 Message Date
ucef 48c3220013 ci(gitea): utilisation de secrets dédiés pour la BDD de production
AS Talange CI/CD Pipeline / Build & Run Unit Tests (push) Successful in 2m48s
AS Talange CI/CD Pipeline / Deploy to Test Environment (push) Has been cancelled
AS Talange CI/CD Pipeline / Deploy to Prod Environment (push) Has been cancelled
2026-06-22 23:52:47 +02:00
ucef f1bd5d9e08 ci(gitea): séparation des déploiements test et prod selon les branches 2026-06-22 23:25:01 +02:00
ucef 5737fb6429 ci(docker): injection des variables Captcha dans docker-compose 2026-06-22 23:25:01 +02:00
ucef 96eee4326a feat(security): configuration dynamique du Captcha Cloudflare Turnstile 2026-06-22 23:25:01 +02:00
4 changed files with 62 additions and 21 deletions
+36 -3
View File
@@ -4,6 +4,7 @@ on:
push:
branches:
- main
- 'prod/*'
jobs:
test:
@@ -26,10 +27,11 @@ jobs:
- name: Run Maven Tests
run: mvn clean test
deploy:
name: Build & Run in Docker Container
deploy_test:
name: Deploy to Test Environment
needs: test
runs-on: self-hosted
if: github.ref == 'refs/heads/main'
runs-on: [self-hosted, test]
container:
image: docker:latest
steps:
@@ -51,3 +53,34 @@ jobs:
echo "POSTGRES_PASSWORD=${DB_PASSWORD:-mypassword}" >> .env
docker compose down app || true
docker compose up -d --build app
deploy_prod:
name: Deploy to Prod Environment
needs: test
if: startsWith(github.ref, 'refs/heads/prod/')
runs-on: [self-hosted, prod]
container:
image: docker:latest
steps:
- name: Clone repository
run: |
apk add --no-cache git
SERVER_URL="${{ github.server_url }}"
SERVER_NO_PROTO="${SERVER_URL#http://}"
SERVER_NO_PROTO="${SERVER_NO_PROTO#https://}"
git clone --depth 1 "https://oauth2:${{ secrets.GITHUB_TOKEN }}@${SERVER_NO_PROTO}/${{ github.repository }}.git" .
git checkout ${{ github.sha }}
- name: Deploy with Docker Compose
env:
PROD_DB_USER: ${{ secrets.PROD_DB_USER }}
PROD_DB_PASSWORD: ${{ secrets.PROD_DB_PASSWORD }}
CAPTCHA_SECRET: ${{ secrets.CAPTCHA_SECRET }}
CAPTCHA_SITEKEY: ${{ secrets.CAPTCHA_SITEKEY }}
run: |
echo "POSTGRES_USER=${PROD_DB_USER:-myuser}" > .env
echo "POSTGRES_PASSWORD=${PROD_DB_PASSWORD:-mypassword}" >> .env
echo "CAPTCHA_SECRET=${CAPTCHA_SECRET:-1x0000000000000000000000000000000AA}" >> .env
echo "CAPTCHA_SITEKEY=${CAPTCHA_SITEKEY:-1x00000000000000000000AA}" >> .env
docker compose down app || true
docker compose up -d --build app
@@ -24,10 +24,10 @@ public class PublicInscriptionController {
private final PreInscriptionRepository preInscriptionRepository;
private final SaisonRepository saisonRepository;
public PublicInscriptionController(CaptchaValidationService captchaValidationService,
TokenPreInscriptionRepository tokenRepository,
PreInscriptionRepository preInscriptionRepository,
SaisonRepository saisonRepository) {
public PublicInscriptionController(CaptchaValidationService captchaValidationService,
TokenPreInscriptionRepository tokenRepository,
PreInscriptionRepository preInscriptionRepository,
SaisonRepository saisonRepository) {
this.captchaValidationService = captchaValidationService;
this.tokenRepository = tokenRepository;
this.preInscriptionRepository = preInscriptionRepository;
@@ -44,13 +44,16 @@ public class PublicInscriptionController {
}
@PostMapping("/demarrer")
public String processDemarrer(@RequestParam("cf-turnstile-response") String captchaResponse, RedirectAttributes redirectAttributes) {
public String processDemarrer(@RequestParam("cf-turnstile-response") String captchaResponse,
RedirectAttributes redirectAttributes) {
Saison activeSaison = saisonRepository.findByEstActiveTrue().orElse(null);
if (activeSaison == null || !activeSaison.getInscriptionsOuvertes()) {
redirectAttributes.addFlashAttribute("error", "Les inscriptions ne sont pas ouvertes pour le moment, veuillez contacter un responsable du club.");
redirectAttributes.addFlashAttribute("error",
"Les inscriptions ne sont pas ouvertes pour le moment, veuillez contacter un responsable du club.");
return "redirect:/inscription-public/demarrer";
}
// En vrai, captchaResponse dépend du fournisseur. Cloudflare Turnstile = cf-turnstile-response
// En vrai, captchaResponse dépend du fournisseur. Cloudflare Turnstile =
// cf-turnstile-response
if (!captchaValidationService.validateCaptcha(captchaResponse)) {
redirectAttributes.addFlashAttribute("error", "Validation CAPTCHA échouée. Veuillez réessayer.");
return "redirect:/inscription-public/demarrer";
@@ -65,13 +68,15 @@ public class PublicInscriptionController {
}
@GetMapping("/formulaire")
public String showFormulaire(@RequestParam("token") String tokenUuid, Model model, RedirectAttributes redirectAttributes) {
public String showFormulaire(@RequestParam("token") String tokenUuid, Model model,
RedirectAttributes redirectAttributes) {
Saison activeSaison = saisonRepository.findByEstActiveTrue().orElse(null);
if (activeSaison == null || !activeSaison.getInscriptionsOuvertes()) {
redirectAttributes.addFlashAttribute("error", "Les inscriptions ne sont pas ouvertes pour le moment, veuillez contacter un responsable du club.");
redirectAttributes.addFlashAttribute("error",
"Les inscriptions ne sont pas ouvertes pour le moment, veuillez contacter un responsable du club.");
return "redirect:/inscription-public/demarrer";
}
TokenPreInscription token = tokenRepository.findByValeurUuid(tokenUuid).orElse(null);
if (token == null || !token.isValide()) {
return "public/lien-expire";
@@ -84,8 +89,8 @@ public class PublicInscriptionController {
@PostMapping("/formulaire")
public String processFormulaire(@RequestParam("token") String tokenUuid,
@ModelAttribute("preInscription") PreInscription preInscription,
RedirectAttributes redirectAttributes) {
@ModelAttribute("preInscription") PreInscription preInscription,
RedirectAttributes redirectAttributes) {
TokenPreInscription token = tokenRepository.findByValeurUuid(tokenUuid).orElse(null);
if (token == null || !token.isValide()) {
return "public/lien-expire";
@@ -93,7 +98,8 @@ public class PublicInscriptionController {
Saison activeSaison = saisonRepository.findByEstActiveTrue().orElse(null);
if (activeSaison == null || !activeSaison.getInscriptionsOuvertes()) {
redirectAttributes.addFlashAttribute("error", "Les inscriptions ne sont pas ouvertes pour le moment, veuillez contacter un responsable du club.");
redirectAttributes.addFlashAttribute("error",
"Les inscriptions ne sont pas ouvertes pour le moment, veuillez contacter un responsable du club.");
return "redirect:/inscription-public/demarrer";
}
@@ -20,15 +20,18 @@
<img src="/images/logo.png" alt="AS Talange" class="h-32 w-auto mx-auto mb-6 object-contain drop-shadow-sm"
onerror="this.style.display='none'">
<h1 class="text-2xl font-bold text-gray-900 mb-2">Inscription au club</h1>
<p th:unless="${inscriptionsFermees}" class="text-gray-600 mb-8">Veuillez valider le captcha pour accéder au formulaire sécurisé.</p>
<p th:unless="${inscriptionsFermees}" class="text-gray-600 mb-8">Veuillez valider le captcha pour accéder au
formulaire sécurisé.</p>
<div th:if="${error != null and (inscriptionsFermees == null or !inscriptionsFermees)}"
class="bg-red-50 text-red-600 p-3 rounded-lg mb-6 text-sm" th:text="${error}"></div>
<div th:if="${error != null and (inscriptionsFermees == null or !inscriptionsFermees)}" class="bg-red-50 text-red-600 p-3 rounded-lg mb-6 text-sm" th:text="${error}"></div>
<div th:if="${inscriptionsFermees}" class="bg-red-50 text-red-600 p-4 rounded-lg mb-6 text-sm font-medium">
Les inscriptions ne sont pas ouvertes pour le moment, veuillez contacter un responsable du club.
</div>
<form th:unless="${inscriptionsFermees}" th:action="@{/inscription-public/demarrer}" method="post" class="flex flex-col items-center">
<form th:unless="${inscriptionsFermees}" th:action="@{/inscription-public/demarrer}" method="post"
class="flex flex-col items-center">
<!-- Remplacer par la vraie clé de site Cloudflare Turnstile -->
<div class="cf-turnstile mb-6" data-sitekey="1x00000000000000000000AA"></div>
-1
View File
@@ -1,4 +1,3 @@
services:
db:
image: postgres:16