-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fcfbe11
commit 9ce3b2c
Showing
20 changed files
with
199 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,8 +25,8 @@ NEXT_PUBLIC_BRAND_OPERATOR_LOGO_ORIENTATION=horizontal | |
TEMPLATES_TMPDIR="./templates_tmp" | ||
TEMPLATES_ADMINS="lilian.sagetlethias,julien.bouquillon" | ||
TEMPLATES_GIT_URL="https://github.com/incubateur-ademe/legal-site-templates-test" | ||
TEMPLATES_GIT_GPG_PRIVATE_KEY="" | ||
TEMPLATES_GIT_GPG_PASSPHRASE="" | ||
TEMPLATES_GIT_GPG_PRIVATE_KEY_BASE64= | ||
TEMPLATES_GIT_GPG_PUBLIC_KEY_BASE64= | ||
TEMPLATES_GIT_COMMITTER_EMAIL="[email protected]" | ||
TEMPLATES_GIT_COMMITTER_NAME="Bot" | ||
TEMPLATES_GIT_MAIN_BRANCH="main" | ||
|
@@ -44,6 +44,7 @@ MAILER_FROM_EMAIL="Pages Légales Faciles <[email protected]>" | |
|
||
## Security | ||
SECURITY_JWT_SECRET="sikretfordevonly" | ||
SECURITY_WEBHOOK_SECRET=="sikretfordevonly" | ||
|
||
## Redis | ||
REDIS_BASE="pages-legales-faciles" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,8 @@ ESPACE_MEMBRE_API_KEY= | |
# TEMPLATES_TMPDIR="./templates_tmp" | ||
# TEMPLATES_ADMINS="lilian.sagetlethias,julien.bouquillon" | ||
TEMPLATES_GIT_URL= | ||
# TEMPLATES_GIT_GPG_PRIVATE_KEY="" | ||
# TEMPLATES_GIT_GPG_PRIVATE_KEY_BASE64="" | ||
# TEMPLATES_GIT_GPG_PUBLIC_KEY_BASE64="" | ||
# TEMPLATES_GIT_GPG_PASSPHRASE="" | ||
TEMPLATES_GIT_COMMITTER_EMAIL="[email protected]" | ||
TEMPLATES_GIT_COMMITTER_NAME="Bot" | ||
|
@@ -49,6 +50,7 @@ MAILER_SMTP_SSL=false | |
|
||
## Security | ||
SECURITY_JWT_SECRET= | ||
SECURITY_WEBHOOK_SECRET= | ||
|
||
## Redis (url or host/port/password) | ||
# REDIS_BASE="pages-legales-faciles" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ name: Teardown review db on PR close | |
|
||
on: | ||
pull_request: | ||
branches: [dev] | ||
types: | ||
- closed | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
web: yarn start | ||
web: ./scripts/import_gpg.sh && yarn start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"jobs": [ | ||
{ | ||
"command": "0 0 * * * ./scripts/call_gpg_refresh_webhook.sh" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,12 +107,12 @@ Française` | |
* No dist value. | ||
* {@link [Local Env Dist](.env.development)} | ||
*/ | ||
TEMPLATES_GIT_GPG_PRIVATE_KEY?: string; | ||
TEMPLATES_GIT_GPG_PRIVATE_KEY_BASE64?: string; | ||
/** | ||
* No dist value. | ||
* {@link [Local Env Dist](.env.development)} | ||
*/ | ||
TEMPLATES_GIT_GPG_PASSPHRASE?: string; | ||
TEMPLATES_GIT_GPG_PUBLIC_KEY_BASE64?: string; | ||
/** | ||
* Dist: `[email protected]` | ||
* {@link [Local Env Dist](.env.development)} | ||
|
@@ -178,6 +178,11 @@ Française` | |
* {@link [Local Env Dist](.env.development)} | ||
*/ | ||
SECURITY_JWT_SECRET?: string; | ||
/** | ||
* Dist: `="sikretfordevonly"` | ||
* {@link [Local Env Dist](.env.development)} | ||
*/ | ||
SECURITY_WEBHOOK_SECRET?: string; | ||
/** | ||
* Dist: `pages-legales-faciles` | ||
* {@link [Local Env Dist](.env.development)} | ||
|
@@ -291,8 +296,8 @@ declare type ProcessEnvCustomKeys = | |
| 'TEMPLATES_TMPDIR' | ||
| 'TEMPLATES_ADMINS' | ||
| 'TEMPLATES_GIT_URL' | ||
| 'TEMPLATES_GIT_GPG_PRIVATE_KEY' | ||
| 'TEMPLATES_GIT_GPG_PASSPHRASE' | ||
| 'TEMPLATES_GIT_GPG_PRIVATE_KEY_BASE64' | ||
| 'TEMPLATES_GIT_GPG_PUBLIC_KEY_BASE64' | ||
| 'TEMPLATES_GIT_COMMITTER_EMAIL' | ||
| 'TEMPLATES_GIT_COMMITTER_NAME' | ||
| 'TEMPLATES_GIT_MAIN_BRANCH' | ||
|
@@ -306,6 +311,7 @@ declare type ProcessEnvCustomKeys = | |
| 'MAILER_SMTP_SSL' | ||
| 'MAILER_FROM_EMAIL' | ||
| 'SECURITY_JWT_SECRET' | ||
| 'SECURITY_WEBHOOK_SECRET' | ||
| 'REDIS_BASE' | ||
| 'REDIS_HOST' | ||
| 'REDIS_PORT' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
|
||
if [ -n "$TEMPLATES_GIT_GPG_PASSPHRASE" ]; then | ||
# URL de l'API et clé API | ||
API_URL="$NEXT_PUBLIC_SITE_URL/api/webhook/gpg/refresh" | ||
API_KEY="$SECURITY_WEBHOOK_SECRET" | ||
|
||
# Exécuter la requête avec curl | ||
response=$(curl -s -X GET "$API_URL" -H "x-api-key: $API_KEY") | ||
|
||
# Vérifier si la requête a réussi | ||
if echo "$response" | grep -q '"ok":true'; then | ||
echo "Succès : $(echo "$response" | jq -r '.message')" | ||
else | ||
echo "Erreur : $(echo "$response" | jq -r '.error')" | ||
fi | ||
else | ||
echo "$(date): No TEMPLATES_GIT_GPG_PASSPHRASE provided. Skipping refresh." >&2 | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/bin/bash | ||
|
||
# Vérifier si les clés publiques et privées sont définies | ||
if [ -z "$TEMPLATES_GIT_GPG_PRIVATE_KEY_BASE64" ] || [ -z "$TEMPLATES_GIT_GPG_PUBLIC_KEY_BASE64" ]; then | ||
echo "Clés GPG non définies. Signature des commits désactivée." | ||
exit 0 | ||
fi | ||
|
||
echo "Les clés GPG sont présentes dans les variables d'environnement. Importation en cours..." | ||
|
||
# Importer la clé privée | ||
echo -n "$TEMPLATES_GIT_GPG_PRIVATE_KEY_BASE64" | base64 --decode | gpg --batch --import | ||
if [ $? -ne 0 ]; then | ||
echo "Erreur : Échec de l'importation de la clé privée." | ||
exit 1 | ||
fi | ||
|
||
# Importer la clé publique | ||
echo -n "$TEMPLATES_GIT_GPG_PUBLIC_KEY_BASE64" | base64 --decode | gpg --batch --import | ||
if [ $? -ne 0 ]; then | ||
echo "Erreur : Échec de l'importation de la clé publique." | ||
exit 1 | ||
fi | ||
|
||
echo "Clés GPG importées avec succès." | ||
|
||
TEMPLATE_GIT_GPG_SIGNINKEY="$(gpg --list-secret-keys --keyid-format LONG | grep sec | awk '{print $2}' | cut -d'/' -f2)" | ||
|
||
# Configurer gpg-agent pour le mode non interactif | ||
echo "allow-loopback-pinentry" >> ~/.gnupg/gpg-agent.conf | ||
echo "default-cache-ttl 115200 " >> ~/.gnupg/gpg-agent.conf # 32 heures (en secondes) | ||
echo "max-cache-ttl 115200" >> ~/.gnupg/gpg-agent.conf | ||
gpgconf --kill gpg-agent | ||
gpgconf --launch gpg-agent | ||
|
||
# Injecter la passphrase dans le cache si nécessaire | ||
if [ -n "$TEMPLATES_GIT_GPG_PASSPHRASE" ]; then | ||
gpg --batch --yes --pinentry-mode loopback --default-key "$TEMPLATE_GIT_GPG_SIGNINKEY" --passphrase "$TEMPLATES_GIT_GPG_PASSPHRASE" --sign <<< "refresh-cache" | ||
if [ $? -eq 0 ]; then | ||
echo "Passphrase injectée avec succès dans le cache." | ||
else | ||
echo "Erreur : Échec de l'injection de la passphrase dans le cache." | ||
exit 1 | ||
fi | ||
fi | ||
|
||
# Configurer Git pour utiliser la clé GPG | ||
git config --global user.signingkey "$TEMPLATE_GIT_GPG_SIGNINKEY" | ||
git config --global commit.gpgSign true | ||
git config --global gpg.program gpg | ||
|
||
echo "Configuration GPG terminée." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
|
||
TEMPLATE_GIT_GPG_SIGNINKEY="$(gpg --list-secret-keys --keyid-format LONG | grep sec | awk '{print $2}' | cut -d'/' -f2)" | ||
# Vérifie et rafraîchit le cache GPG | ||
if [ -n "$TEMPLATES_GIT_GPG_PASSPHRASE" ]; then | ||
gpg --batch --yes --pinentry-mode loopback --default-key "$TEMPLATE_GIT_GPG_SIGNINKEY" --passphrase "$TEMPLATES_GIT_GPG_PASSPHRASE" --sign <<< "refresh-cache" > /dev/null 2>&1 | ||
if [ $? -eq 0 ]; then | ||
echo "$(date): GPG cache refreshed successfully for 32 hours." | ||
else | ||
echo "$(date): Failed to refresh GPG cache." >&2 | ||
exit 1 | ||
fi | ||
else | ||
echo "$(date): No TEMPLATES_GIT_GPG_PASSPHRASE provided. Skipping refresh." >&2 | ||
exit 1 | ||
fi |
Oops, something went wrong.