ci: run tests and audit on every push, deploy exact commit with health check
- npm audit fix (multer 2.5.0, body-parser, qs, proxy-addr): 0 vulnerabilities - engines node >=22.9 and .nvmrc (prod runs Node 26) - GET /healthz for deployment checks - workflow: check job (npm ci, npm test, npm audit) on every push; deploy only on main after checks, with pinned host key, BatchMode and exact commit SHA - ops/deploy-gameservers-control.sh: lock, refuse dirty tree, fast-forward to the commit, npm ci --omit=dev, wait for /healthz, roll back on failure - stop tracking storage/servers.json (prod storage now lives outside the repo) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
655cf655da
commit
0a7bfc183d
10 changed files with 249 additions and 129 deletions
|
|
@ -1,28 +1,69 @@
|
||||||
name: Deploy Gameservers Control
|
name: Deploy Gameservers Control
|
||||||
|
|
||||||
|
# Les contrôles tournent à chaque push, sur toutes les branches (une PR est donc contrôlée par
|
||||||
|
# le push de sa branche) ; le déploiement, seulement après un push sur main dont les
|
||||||
|
# contrôles ont réussi.
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
check:
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
|
timeout-minutes: 10
|
||||||
|
# Même version majeure de Node que la prod (v26 sur webapps).
|
||||||
|
container:
|
||||||
|
image: node:26-bookworm
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: https://data.forgejo.org/actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm ci --no-fund
|
||||||
|
- name: Tests
|
||||||
|
run: npm test
|
||||||
|
- name: Audit des dépendances de production
|
||||||
|
run: npm audit --omit=dev --audit-level=high
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
needs: check
|
||||||
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
||||||
|
runs-on: docker
|
||||||
|
timeout-minutes: 10
|
||||||
|
container:
|
||||||
|
image: node:26-bookworm
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Deploy on WebApps
|
- name: Deploy on WebApps
|
||||||
env:
|
env:
|
||||||
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
|
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||||
|
# Clé d'hôte de la VM (sortie de `ssh-keyscan -p 2911 192.168.0.100`) : sans elle,
|
||||||
|
# n'importe quelle machine qui répondrait à cette adresse recevrait la connexion.
|
||||||
|
DEPLOY_KNOWN_HOSTS: ${{ secrets.DEPLOY_KNOWN_HOSTS }}
|
||||||
|
DEPLOY_COMMIT: ${{ github.sha }}
|
||||||
run: |
|
run: |
|
||||||
apt-get update
|
if ! command -v ssh >/dev/null; then
|
||||||
apt-get install -y openssh-client
|
apt-get update
|
||||||
|
apt-get install -y --no-install-recommends openssh-client
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$DEPLOY_KNOWN_HOSTS" ]; then
|
||||||
|
echo "Secret DEPLOY_KNOWN_HOSTS manquant (ssh-keyscan -p 2911 192.168.0.100)" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
printf '%s' "$DEPLOY_COMMIT" | grep -Eq '^[0-9a-f]{40}$'
|
||||||
|
|
||||||
|
umask 077
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
printf '%s\n' "$DEPLOY_SSH_KEY" > ~/.ssh/id_ed25519
|
printf '%s\n' "$DEPLOY_SSH_KEY" > ~/.ssh/id_ed25519
|
||||||
chmod 600 ~/.ssh/id_ed25519
|
printf '%s\n' "$DEPLOY_KNOWN_HOSTS" > ~/.ssh/known_hosts
|
||||||
|
|
||||||
ssh -o StrictHostKeyChecking=no \
|
# La clé n'autorise que des commandes précises côté serveur
|
||||||
|
# (/usr/local/sbin/deploy-ssh-gate) : garder exactement cette forme.
|
||||||
|
ssh -o BatchMode=yes -o StrictHostKeyChecking=yes \
|
||||||
-i ~/.ssh/id_ed25519 \
|
-i ~/.ssh/id_ed25519 \
|
||||||
-p 2911 \
|
-p 2911 \
|
||||||
shinuwa@192.168.0.100 \
|
shinuwa@192.168.0.100 \
|
||||||
"sudo /usr/local/bin/deploy-gameservers-control"
|
"sudo /usr/local/bin/deploy-gameservers-control --commit '$DEPLOY_COMMIT'"
|
||||||
|
|
||||||
|
- name: Remove the deployment key
|
||||||
|
if: always()
|
||||||
|
run: rm -f ~/.ssh/id_ed25519
|
||||||
|
|
|
||||||
1
.nvmrc
Normal file
1
.nvmrc
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
26
|
||||||
|
|
@ -53,3 +53,12 @@ Au premier demarrage, si aucun groupe n'existe, un groupe `admin` est cree et so
|
||||||
- `storage/groups.json`: groupes et permissions.
|
- `storage/groups.json`: groupes et permissions.
|
||||||
- `storage/launch-logs.json`: lancements conserves 7 jours.
|
- `storage/launch-logs.json`: lancements conserves 7 jours.
|
||||||
- `mocked/dev-gameservers-status.json`: statut mock de developpement.
|
- `mocked/dev-gameservers-status.json`: statut mock de developpement.
|
||||||
|
|
||||||
|
Le dossier `storage/` n'est pas versionne: il est cree au premier demarrage avec des valeurs
|
||||||
|
par defaut. En production, `STORAGE_DIR` pointe hors du depot (droits `700`).
|
||||||
|
|
||||||
|
## Deploiement
|
||||||
|
|
||||||
|
Chaque push lance les tests et `npm audit` (`.forgejo/workflows/deploy.yml`). Un push sur `main`
|
||||||
|
dont les controles passent deploie le commit en production. Mise en place cote serveur:
|
||||||
|
voir [ops/README.md](ops/README.md).
|
||||||
|
|
|
||||||
41
ops/README.md
Normal file
41
ops/README.md
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
# Exploitation
|
||||||
|
|
||||||
|
## Déploiement
|
||||||
|
|
||||||
|
La CI se connecte en SSH à la VM webapps (`shinuwa@192.168.0.100:2911`) avec la clé
|
||||||
|
`forgejo-runner@webapps`, puis lance :
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo /usr/local/bin/deploy-gameservers-control --commit '<sha>'
|
||||||
|
```
|
||||||
|
|
||||||
|
Côté serveur, cette clé est limitée par `/usr/local/sbin/deploy-ssh-gate` (commande forcée dans
|
||||||
|
`~/.ssh/authorized_keys`) : toute nouvelle commande SSH dans le workflow doit y être ajoutée.
|
||||||
|
|
||||||
|
### Secrets Forgejo du dépôt
|
||||||
|
|
||||||
|
| Secret | Contenu |
|
||||||
|
|---|---|
|
||||||
|
| `DEPLOY_SSH_KEY` | Clé privée `forgejo-runner@webapps` |
|
||||||
|
| `DEPLOY_KNOWN_HOSTS` | Sortie de `ssh-keyscan -p 2911 192.168.0.100` |
|
||||||
|
|
||||||
|
### Installer ou mettre à jour le script de déploiement
|
||||||
|
|
||||||
|
Sur la VM webapps, depuis le dépôt à jour :
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo install -o root -g root -m 755 ops/deploy-gameservers-control.sh /usr/local/bin/deploy-gameservers-control
|
||||||
|
```
|
||||||
|
|
||||||
|
Le script :
|
||||||
|
|
||||||
|
1. prend un verrou, pour qu'un seul déploiement tourne à la fois ;
|
||||||
|
2. refuse de déployer si des fichiers suivis par git ont été modifiés à la main en prod ;
|
||||||
|
3. avance `main` jusqu'au commit demandé (avance rapide seulement, jamais de recul) ;
|
||||||
|
4. lance `npm ci --omit=dev`, redémarre le service, puis attend `/healthz` pendant 30 s ;
|
||||||
|
5. si `/healthz` ne répond pas, revient au commit précédent et termine en erreur.
|
||||||
|
|
||||||
|
## Données
|
||||||
|
|
||||||
|
`STORAGE_DIR` pointe hors du dépôt (`/data/webapps/data/gameservers-control`, droits `700`,
|
||||||
|
fichiers `600`).
|
||||||
94
ops/deploy-gameservers-control.sh
Executable file
94
ops/deploy-gameservers-control.sh
Executable file
|
|
@ -0,0 +1,94 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# Rôle : déploie un commit de main en production sur la VM webapps.
|
||||||
|
# Installé dans /usr/local/bin/deploy-gameservers-control (root:root, 755) et lancé par la CI
|
||||||
|
# via `sudo /usr/local/bin/deploy-gameservers-control --commit <sha>` (cf. ops/README.md).
|
||||||
|
#
|
||||||
|
# Étapes : verrou -> contrôle du dépôt -> avance rapide jusqu'au commit -> npm ci -> redémarrage
|
||||||
|
# -> attente de /healthz. Si /healthz ne répond pas, retour automatique au commit précédent.
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
APP_DIR=/data/webapps/apps/gameservers-control
|
||||||
|
APP_USER=shinuwa
|
||||||
|
SERVICE=gameservers-control
|
||||||
|
NODE_BIN=/home/shinuwa/.nvm/versions/node/v26.3.0/bin
|
||||||
|
LOCK_FILE=/run/lock/deploy-gameservers-control.lock
|
||||||
|
HEALTH_TRIES=30
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
echo "Usage: $0 [--commit <sha complet de 40 caractères>]" >&2
|
||||||
|
exit 2
|
||||||
|
}
|
||||||
|
|
||||||
|
COMMIT=""
|
||||||
|
if [[ $# -gt 0 ]]; then
|
||||||
|
[[ $# -eq 2 && "$1" == "--commit" && "$2" =~ ^[0-9a-f]{40}$ ]] || usage
|
||||||
|
COMMIT="$2"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Un seul déploiement à la fois : un second attend la fin du premier.
|
||||||
|
exec 9>"$LOCK_FILE"
|
||||||
|
flock 9
|
||||||
|
|
||||||
|
as_app() {
|
||||||
|
sudo -u "$APP_USER" env PATH="$NODE_BIN:/usr/bin:/bin" HOME="/home/$APP_USER" "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
cd "$APP_DIR"
|
||||||
|
|
||||||
|
# Refuse de déployer par-dessus des modifications locales de fichiers suivis par git :
|
||||||
|
# un correctif fait à la main en prod serait écrasé ou bloquerait l'avance rapide.
|
||||||
|
if [[ -n "$(as_app git status --porcelain --untracked-files=no)" ]]; then
|
||||||
|
echo "Modifications locales dans $APP_DIR, déploiement annulé :" >&2
|
||||||
|
as_app git status --short --untracked-files=no >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
as_app git fetch --prune origin main
|
||||||
|
TARGET="${COMMIT:-$(as_app git rev-parse origin/main)}"
|
||||||
|
|
||||||
|
if ! as_app git merge-base --is-ancestor "$TARGET" origin/main; then
|
||||||
|
echo "Le commit $TARGET n'est pas sur origin/main, déploiement annulé." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
PREVIOUS="$(as_app git rev-parse HEAD)"
|
||||||
|
# Un commit plus ancien que celui en place (CI en retard) ne fait pas reculer la prod.
|
||||||
|
as_app git merge --ff-only "$TARGET"
|
||||||
|
DEPLOYED="$(as_app git rev-parse HEAD)"
|
||||||
|
echo "Commit en place : $DEPLOYED (précédent : $PREVIOUS)"
|
||||||
|
|
||||||
|
PORT="$(sed -n 's/^PORT=//p' .env 2>/dev/null | tail -n 1)"
|
||||||
|
HEALTH_URL="http://127.0.0.1:${PORT:-3100}/healthz"
|
||||||
|
|
||||||
|
install_and_restart() {
|
||||||
|
as_app npm ci --omit=dev --no-audit --no-fund
|
||||||
|
systemctl restart "$SERVICE"
|
||||||
|
}
|
||||||
|
|
||||||
|
wait_healthy() {
|
||||||
|
local i
|
||||||
|
for ((i = 1; i <= HEALTH_TRIES; i++)); do
|
||||||
|
if curl -fsS --max-time 2 "$HEALTH_URL" >/dev/null 2>&1; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
install_and_restart
|
||||||
|
if wait_healthy; then
|
||||||
|
echo "Déploiement OK : $DEPLOYED répond sur $HEALTH_URL"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "$HEALTH_URL ne répond pas après ${HEALTH_TRIES}s, retour à $PREVIOUS." >&2
|
||||||
|
journalctl -u "$SERVICE" -n 30 --no-pager >&2 || true
|
||||||
|
as_app git reset --hard "$PREVIOUS"
|
||||||
|
install_and_restart
|
||||||
|
if wait_healthy; then
|
||||||
|
echo "Retour arrière OK : $PREVIOUS est de nouveau en place." >&2
|
||||||
|
else
|
||||||
|
echo "Le retour arrière ne répond pas non plus : intervention manuelle nécessaire." >&2
|
||||||
|
fi
|
||||||
|
exit 1
|
||||||
144
package-lock.json
generated
144
package-lock.json
generated
|
|
@ -9,9 +9,12 @@
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"express": "^5.1.0",
|
"express": "^5.1.0",
|
||||||
"multer": "^2.0.2"
|
"multer": "^2.5.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {}
|
"devDependencies": {},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=22.9"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"node_modules/accepts": {
|
"node_modules/accepts": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
|
|
@ -33,20 +36,20 @@
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/body-parser": {
|
"node_modules/body-parser": {
|
||||||
"version": "2.2.2",
|
"version": "2.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.4.0.tgz",
|
||||||
"integrity": "sha512-oP5VkATKlNwcgvxi0vM0p/D3n2C3EReYVX+DNYs5TjZFn/oQt2j+4sVJtSMr18pdRr8wjTcBl6LoV+FUwzPmNA==",
|
"integrity": "sha512-Ifk1KcLrxaGt1occQagQNFNNOqRt1LFuehEnHHzB8Z6cRgIxRU1TBaiIsUiCdA+gy5PL7Y1IX31DNKkRmxtXjQ==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bytes": "^3.1.2",
|
"bytes": "^3.1.2",
|
||||||
"content-type": "^1.0.5",
|
"content-type": "^2.1.0",
|
||||||
"debug": "^4.4.3",
|
"debug": "^4.4.3",
|
||||||
"http-errors": "^2.0.0",
|
"http-errors": "^2.0.1",
|
||||||
"iconv-lite": "^0.7.0",
|
"iconv-lite": "^0.7.3",
|
||||||
"on-finished": "^2.4.1",
|
"on-finished": "^2.4.1",
|
||||||
"qs": "^6.14.1",
|
"qs": "^6.16.1",
|
||||||
"raw-body": "^3.0.1",
|
"raw-body": "^3.0.2",
|
||||||
"type-is": "^2.0.1"
|
"type-is": "^2.1.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18"
|
"node": ">=18"
|
||||||
|
|
@ -56,11 +59,18 @@
|
||||||
"url": "https://opencollective.com/express"
|
"url": "https://opencollective.com/express"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/buffer-from": {
|
"node_modules/body-parser/node_modules/content-type": {
|
||||||
"version": "1.1.2",
|
"version": "2.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/content-type/-/content-type-2.1.0.tgz",
|
||||||
"integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==",
|
"integrity": "sha512-mj7UPXE0jaqaOsukNZRUEfEi2AcL7C/vwmwcHV0O97eO1E1pxBZuyjlZrx5seTaNBg1U6+o35wpa35Qfcc+7ag==",
|
||||||
"license": "MIT"
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/express"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"node_modules/busboy": {
|
"node_modules/busboy": {
|
||||||
"version": "1.6.0",
|
"version": "1.6.0",
|
||||||
|
|
@ -111,21 +121,6 @@
|
||||||
"url": "https://github.com/sponsors/ljharb"
|
"url": "https://github.com/sponsors/ljharb"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/concat-stream": {
|
|
||||||
"version": "2.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-2.0.0.tgz",
|
|
||||||
"integrity": "sha512-MWufYdFw53ccGjCA+Ol7XJYpAlW6/prSMzuPOTRnJGcGzuhLn4Scrz7qf6o8bROZ514ltazcIFJZevcfbo0x7A==",
|
|
||||||
"engines": [
|
|
||||||
"node >= 6.0"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"buffer-from": "^1.0.0",
|
|
||||||
"inherits": "^2.0.3",
|
|
||||||
"readable-stream": "^3.0.2",
|
|
||||||
"typedarray": "^0.0.6"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/content-disposition": {
|
"node_modules/content-disposition": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.1.0.tgz",
|
||||||
|
|
@ -451,9 +446,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/iconv-lite": {
|
"node_modules/iconv-lite": {
|
||||||
"version": "0.7.2",
|
"version": "0.7.3",
|
||||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.2.tgz",
|
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.3.tgz",
|
||||||
"integrity": "sha512-im9DjEDQ55s9fL4EYzOAv0yMqmMBSZp6G0VvFyTMPKWxiSBHUj9NW/qqLmXUwXrrM7AvqSlTCfvqRb0cM8yYqw==",
|
"integrity": "sha512-IKXpvIzjnC9XTAUbVBcMfGS0EPaIXtW6v+zr+RRp+hqULEpo0owZax6wyRwPOJbWbzjYspQwusTsfVr0ifh4uQ==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"safer-buffer": ">= 2.1.2 < 3.0.0"
|
"safer-buffer": ">= 2.1.2 < 3.0.0"
|
||||||
|
|
@ -549,14 +544,13 @@
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/multer": {
|
"node_modules/multer": {
|
||||||
"version": "2.1.1",
|
"version": "2.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/multer/-/multer-2.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/multer/-/multer-2.5.0.tgz",
|
||||||
"integrity": "sha512-mo+QTzKlx8R7E5ylSXxWzGoXoZbOsRMpyitcht8By2KHvMbf3tjwosZ/Mu/XYU6UuJ3VZnODIrak5ZrPiPyB6A==",
|
"integrity": "sha512-BsqOzYGVq49JcW2IzoSAxeKYRevb+dGGPPWleOR8Lrlk4igwxu1/9pwSXlByhCb7MVZDrNJFC0IBP5/O5nLYRw==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"append-field": "^1.0.0",
|
"append-field": "^1.0.0",
|
||||||
"busboy": "^1.6.0",
|
"busboy": "^1.6.0",
|
||||||
"concat-stream": "^2.0.0",
|
|
||||||
"type-is": "^1.6.18"
|
"type-is": "^1.6.18"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|
@ -672,9 +666,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/proxy-addr": {
|
"node_modules/proxy-addr": {
|
||||||
"version": "2.0.7",
|
"version": "2.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
|
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.8.tgz",
|
||||||
"integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==",
|
"integrity": "sha512-5nnx0yGyVUcY6t9RnWcARWtwT9F1D8O9rt08htPvnd49W1IgZtmLkhu9WfMzQj1cFxjHIO6connUNVW5k7AVyQ==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"forwarded": "0.2.0",
|
"forwarded": "0.2.0",
|
||||||
|
|
@ -682,15 +676,20 @@
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 0.10"
|
"node": ">= 0.10"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/express"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/qs": {
|
"node_modules/qs": {
|
||||||
"version": "6.15.2",
|
"version": "6.17.1",
|
||||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.15.2.tgz",
|
"resolved": "https://registry.npmjs.org/qs/-/qs-6.17.1.tgz",
|
||||||
"integrity": "sha512-Rzq0KEyX/w/tEybncDgdkZrJgVUsUMk3xjh3t5bv3S1HTAtg+uOYt72+ZfwiQwKdysThkTBdL/rTi6HDmX9Ddw==",
|
"integrity": "sha512-jd3COkaKVgGUW+ZHyEHCG9bH7RoaaiWuMgzsIBjUMVjLAaWGWpoUAVwljVvBHxRu/2qEHnadLGZrkutYUBPQJA==",
|
||||||
"license": "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"side-channel": "^1.1.0"
|
"es-define-property": "^1.0.1",
|
||||||
|
"side-channel": "^1.1.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.6"
|
"node": ">=0.6"
|
||||||
|
|
@ -723,20 +722,6 @@
|
||||||
"node": ">= 0.10"
|
"node": ">= 0.10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/readable-stream": {
|
|
||||||
"version": "3.6.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz",
|
|
||||||
"integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"inherits": "^2.0.3",
|
|
||||||
"string_decoder": "^1.1.1",
|
|
||||||
"util-deprecate": "^1.0.1"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 6"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/router": {
|
"node_modules/router": {
|
||||||
"version": "2.2.0",
|
"version": "2.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/router/-/router-2.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/router/-/router-2.2.0.tgz",
|
||||||
|
|
@ -753,26 +738,6 @@
|
||||||
"node": ">= 18"
|
"node": ">= 18"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/safe-buffer": {
|
|
||||||
"version": "5.2.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
|
|
||||||
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
|
|
||||||
"funding": [
|
|
||||||
{
|
|
||||||
"type": "github",
|
|
||||||
"url": "https://github.com/sponsors/feross"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "patreon",
|
|
||||||
"url": "https://www.patreon.com/feross"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "consulting",
|
|
||||||
"url": "https://feross.org/support"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"license": "MIT"
|
|
||||||
},
|
|
||||||
"node_modules/safer-buffer": {
|
"node_modules/safer-buffer": {
|
||||||
"version": "2.1.2",
|
"version": "2.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
||||||
|
|
@ -919,15 +884,6 @@
|
||||||
"node": ">=10.0.0"
|
"node": ">=10.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/string_decoder": {
|
|
||||||
"version": "1.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz",
|
|
||||||
"integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"safe-buffer": "~5.2.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/toidentifier": {
|
"node_modules/toidentifier": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
|
||||||
|
|
@ -968,12 +924,6 @@
|
||||||
"url": "https://opencollective.com/express"
|
"url": "https://opencollective.com/express"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/typedarray": {
|
|
||||||
"version": "0.0.6",
|
|
||||||
"resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
|
|
||||||
"integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==",
|
|
||||||
"license": "MIT"
|
|
||||||
},
|
|
||||||
"node_modules/unpipe": {
|
"node_modules/unpipe": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
|
||||||
|
|
@ -983,12 +933,6 @@
|
||||||
"node": ">= 0.8"
|
"node": ">= 0.8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/util-deprecate": {
|
|
||||||
"version": "1.0.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
|
||||||
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==",
|
|
||||||
"license": "MIT"
|
|
||||||
},
|
|
||||||
"node_modules/vary": {
|
"node_modules/vary": {
|
||||||
"version": "1.1.2",
|
"version": "1.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,9 @@
|
||||||
"description": "Interface web de controle des serveurs de jeux",
|
"description": "Interface web de controle des serveurs de jeux",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "src/server.js",
|
"main": "src/server.js",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=22.9"
|
||||||
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node --env-file-if-exists=.env src/server.js",
|
"start": "node --env-file-if-exists=.env src/server.js",
|
||||||
"dev": "NODE_ENV=development node --env-file-if-exists=.env src/server.js",
|
"dev": "NODE_ENV=development node --env-file-if-exists=.env src/server.js",
|
||||||
|
|
@ -11,7 +14,7 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"express": "^5.1.0",
|
"express": "^5.1.0",
|
||||||
"multer": "^2.0.2"
|
"multer": "^2.5.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {}
|
"devDependencies": {}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import { serversRouter } from "./routes/servers.js";
|
||||||
function createApp() {
|
function createApp() {
|
||||||
const app = express();
|
const app = express();
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
|
app.get("/healthz", (_req, res) => res.json({ ok: true }));
|
||||||
app.use("/server-images", express.static(config.serverImagesDir));
|
app.use("/server-images", express.static(config.serverImagesDir));
|
||||||
|
|
||||||
app.use("/api", authRouter);
|
app.use("/api", authRouter);
|
||||||
|
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
[
|
|
||||||
{
|
|
||||||
"id": "game-1",
|
|
||||||
"game": "Jeu 1",
|
|
||||||
"address": "srv.mocked.com:12345",
|
|
||||||
"port": 12345,
|
|
||||||
"startProfile": "GAME_1",
|
|
||||||
"secrets": {}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "game-2",
|
|
||||||
"game": "Jeu 2",
|
|
||||||
"address": "srv.mocked.com:67890",
|
|
||||||
"port": 67890,
|
|
||||||
"startProfile": "GAME_2",
|
|
||||||
"secrets": {
|
|
||||||
"password": "change-me"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
@ -90,6 +90,12 @@ const baseUrl = `http://127.0.0.1:${server.address().port}`;
|
||||||
|
|
||||||
test.after(() => server.close());
|
test.after(() => server.close());
|
||||||
|
|
||||||
|
test("healthz answers without authentication", async () => {
|
||||||
|
const response = await request("/healthz");
|
||||||
|
assert.equal(response.status, 200);
|
||||||
|
assert.deepEqual(response.body, { ok: true });
|
||||||
|
});
|
||||||
|
|
||||||
test("rejects invalid password and accepts group password", async () => {
|
test("rejects invalid password and accepts group password", async () => {
|
||||||
const rejected = await request("/api/login", {
|
const rejected = await request("/api/login", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue