Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
9e4d959
chore: add .venv to .gitignore
NathanTesseyre May 21, 2026
962f538
fix: correct flask package name in requirements.txt
NathanTesseyre May 21, 2026
a9ef921
fix: add missing colon in app.py
NathanTesseyre May 21, 2026
a344db5
fix: add missing colon in app.py
NathanTesseyre May 21, 2026
002e7dc
fix: use english variable name errors instead of erreurs in app.py
NathanTesseyre May 21, 2026
e5f14a7
fix: use english variable name errors instead of erreurs in app.py
NathanTesseyre May 21, 2026
f587d9b
fix: update API port in config.json
NathanTesseyre May 21, 2026
1ad2514
fix: update API port in config.json
NathanTesseyre May 21, 2026
eca1a7c
fix: hardcode log filename instead of uninitialized variable in app.py
NathanTesseyre May 21, 2026
96dc6c2
chore: remove outdated comments in app.py
NathanTesseyre May 21, 2026
4d1fa7f
fix: correct axios import typo
NathanTesseyre May 21, 2026
fa4791f
chore: use axios conventional response.data instead of response.body
NathanTesseyre May 21, 2026
4fcdc3f
fix: correct axios dependency name in package.json
NathanTesseyre May 21, 2026
c8a69eb
chore: add node_modules dir in .gitignore
NathanTesseyre May 21, 2026
a4b9a2d
chore: add package-lock.json
NathanTesseyre May 21, 2026
d866a69
feat: add api key on each axios request on node
NathanTesseyre May 21, 2026
73cdf18
feat: add API key authentication to python-api
NathanTesseyre May 21, 2026
8442c74
fix: add request import on app.py
NathanTesseyre May 21, 2026
81f37a6
refactor: centralize API key in config.json
NathanTesseyre May 21, 2026
94862d7
chore: use config.json to load log_file in app.py instead of hardcode…
NathanTesseyre May 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"port": 5000,
"host": "localhost",
"route": "/api/logs",
"log_file": "server.log"
"log_file": "server.log",
"key": "devsecops-simplon-2024"
}
}
6 changes: 5 additions & 1 deletion node-client/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ const axios = require('axios');

async function getLogs() {
try {
const response = await axios.get(API_URL);
const response = await axios.get(API_URL, {
headers: {
'X-API-Key': `${config.api.key}`
}
});

const data = response.data;

Expand Down
10 changes: 9 additions & 1 deletion python-api/app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from flask import Flask, jsonify
from flask import Flask, jsonify, request
import json
import os

Expand Down Expand Up @@ -39,9 +39,17 @@ def parse_logs(filepath):
"warnings": warnings
}

def verifier_cle_api():
cle = request.headers.get("X-API-Key")
if cle != config["api"]["key"]:
return jsonify({"erreur": "Clé API invalide ou manquante"}), 401
return None

@app.route("/api/logs", methods=["GET"])
def get_logs():
erreur = verifier_cle_api()
if erreur:
return erreur
result = parse_logs(config["api"]["log_file"])
return jsonify(result), 200

Expand Down
Loading