chore: JSON-404 fuer die API, Login-Validator entschlacken, Altlasten entfernen
- Unbekannte Pfade unter /api fielen bis zum Express-Standard durch und
lieferten eine HTML-Seite ("Cannot GET /api/foo"), mit der ein JSON-Client
nichts anfangen kann. Es gab keinen 404-Handler; errorHandler greift nur
bei next(err). Jetzt antwortet /api mit JSON und Status 404.
- validateLogin verlangte fuer das EINGEGEBENE Passwort mindestens 6 Zeichen.
Eine Policy gehoert nicht in den Login-Pfad: kurze Eingaben lieferten 400
"Validierungsfehler" statt 401 und verrieten damit etwas ueber die Regeln;
ausserdem widersprach der Wert dem minlength: 12 des Admin-Schemas.
Geprueft: kurzes Passwort liefert jetzt 401.
- d9fecb6 hatte versehentlich ein backend/-Verzeichnis im Repo-Wurzel
eingecheckt (leere .gitignore, zwei 0-Byte-Logdateien) — ausserhalb jeder
App. Entfernt und im Wurzel-.gitignore gegen Wiederkehr abgesichert.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
e2af87a7e5
commit
2950f09485
|
|
@ -17,3 +17,7 @@ portal/ssl/
|
||||||
# OS
|
# OS
|
||||||
.DS_Store
|
.DS_Store
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
|
|
||||||
|
# Versehentlich angelegte Log-Verzeichnisse
|
||||||
|
logs/
|
||||||
|
*.log
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,13 @@ const validateLogin = [
|
||||||
.trim()
|
.trim()
|
||||||
.notEmpty()
|
.notEmpty()
|
||||||
.withMessage('Benutzername ist erforderlich'),
|
.withMessage('Benutzername ist erforderlich'),
|
||||||
|
// Keine Laengenpruefung: eine Passwort-Policy gehoert nicht in den
|
||||||
|
// Login-Pfad. Sie liefert 400 statt 401 und verraet damit unnoetig etwas
|
||||||
|
// ueber die Regeln; ausserdem widersprach der Wert dem minlength des
|
||||||
|
// Admin-Schemas.
|
||||||
body('password')
|
body('password')
|
||||||
.notEmpty()
|
.notEmpty()
|
||||||
.withMessage('Passwort ist erforderlich')
|
.withMessage('Passwort ist erforderlich'),
|
||||||
.isLength({ min: 6 })
|
|
||||||
.withMessage('Passwort muss mindestens 6 Zeichen lang sein'),
|
|
||||||
handleValidationErrors
|
handleValidationErrors
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,13 @@ app.use('/api', require('./routes/auditRoutes'));
|
||||||
app.use('/api/config', require('./routes/configRoutes'));
|
app.use('/api/config', require('./routes/configRoutes'));
|
||||||
app.use('/api/drohnenfuehrer', require('./routes/drohnenfuehrerRoutes'));
|
app.use('/api/drohnenfuehrer', require('./routes/drohnenfuehrerRoutes'));
|
||||||
|
|
||||||
|
// Unbekannte API-Pfade als JSON beantworten. Ohne das faellt die Anfrage bis zum
|
||||||
|
// Express-Standard durch und liefert eine HTML-Seite ("Cannot GET /api/foo"),
|
||||||
|
// mit der ein JSON-Client nichts anfangen kann.
|
||||||
|
app.use('/api', (req, res) => {
|
||||||
|
res.status(404).json({ success: false, message: 'Endpunkt nicht gefunden' });
|
||||||
|
});
|
||||||
|
|
||||||
// Health check with basic system info
|
// Health check with basic system info
|
||||||
app.get('/health', async (req, res) => {
|
app.get('/health', async (req, res) => {
|
||||||
const dbStatus = mongoose.connection.readyState === 1 ? 'connected' : 'disconnected';
|
const dbStatus = mongoose.connection.readyState === 1 ? 'connected' : 'disconnected';
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,13 @@ const validateLogin = [
|
||||||
.trim()
|
.trim()
|
||||||
.notEmpty()
|
.notEmpty()
|
||||||
.withMessage('Benutzername ist erforderlich'),
|
.withMessage('Benutzername ist erforderlich'),
|
||||||
|
// Keine Laengenpruefung: eine Passwort-Policy gehoert nicht in den
|
||||||
|
// Login-Pfad. Sie liefert 400 statt 401 und verraet damit unnoetig etwas
|
||||||
|
// ueber die Regeln; ausserdem widersprach der Wert dem minlength des
|
||||||
|
// Admin-Schemas.
|
||||||
body('password')
|
body('password')
|
||||||
.notEmpty()
|
.notEmpty()
|
||||||
.withMessage('Passwort ist erforderlich')
|
.withMessage('Passwort ist erforderlich'),
|
||||||
.isLength({ min: 6 })
|
|
||||||
.withMessage('Passwort muss mindestens 6 Zeichen lang sein'),
|
|
||||||
handleValidationErrors
|
handleValidationErrors
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,13 @@ app.use('/api', require('./routes/auditRoutes'));
|
||||||
app.use('/api/config', require('./routes/configRoutes'));
|
app.use('/api/config', require('./routes/configRoutes'));
|
||||||
app.use('/api/handler', require('./routes/handlerRoutes'));
|
app.use('/api/handler', require('./routes/handlerRoutes'));
|
||||||
|
|
||||||
|
// Unbekannte API-Pfade als JSON beantworten. Ohne das faellt die Anfrage bis zum
|
||||||
|
// Express-Standard durch und liefert eine HTML-Seite ("Cannot GET /api/foo"),
|
||||||
|
// mit der ein JSON-Client nichts anfangen kann.
|
||||||
|
app.use('/api', (req, res) => {
|
||||||
|
res.status(404).json({ success: false, message: 'Endpunkt nicht gefunden' });
|
||||||
|
});
|
||||||
|
|
||||||
// Health check with basic system info
|
// Health check with basic system info
|
||||||
app.get('/health', async (req, res) => {
|
app.get('/health', async (req, res) => {
|
||||||
const dbStatus = mongoose.connection.readyState === 1 ? 'connected' : 'disconnected';
|
const dbStatus = mongoose.connection.readyState === 1 ? 'connected' : 'disconnected';
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,13 @@ const validateLogin = [
|
||||||
.trim()
|
.trim()
|
||||||
.notEmpty()
|
.notEmpty()
|
||||||
.withMessage('Benutzername ist erforderlich'),
|
.withMessage('Benutzername ist erforderlich'),
|
||||||
|
// Keine Laengenpruefung: eine Passwort-Policy gehoert nicht in den
|
||||||
|
// Login-Pfad. Sie liefert 400 statt 401 und verraet damit unnoetig etwas
|
||||||
|
// ueber die Regeln; ausserdem widersprach der Wert dem minlength des
|
||||||
|
// Admin-Schemas.
|
||||||
body('password')
|
body('password')
|
||||||
.notEmpty()
|
.notEmpty()
|
||||||
.withMessage('Passwort ist erforderlich')
|
.withMessage('Passwort ist erforderlich'),
|
||||||
.isLength({ min: 6 })
|
|
||||||
.withMessage('Passwort muss mindestens 6 Zeichen lang sein'),
|
|
||||||
handleValidationErrors
|
handleValidationErrors
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,13 @@ app.use('/api', require('./routes/auditRoutes'));
|
||||||
app.use('/api/config', require('./routes/configRoutes'));
|
app.use('/api/config', require('./routes/configRoutes'));
|
||||||
app.use('/api/stoeberhundefuehrer', require('./routes/stoeberhundefuehrerRoutes'));
|
app.use('/api/stoeberhundefuehrer', require('./routes/stoeberhundefuehrerRoutes'));
|
||||||
|
|
||||||
|
// Unbekannte API-Pfade als JSON beantworten. Ohne das faellt die Anfrage bis zum
|
||||||
|
// Express-Standard durch und liefert eine HTML-Seite ("Cannot GET /api/foo"),
|
||||||
|
// mit der ein JSON-Client nichts anfangen kann.
|
||||||
|
app.use('/api', (req, res) => {
|
||||||
|
res.status(404).json({ success: false, message: 'Endpunkt nicht gefunden' });
|
||||||
|
});
|
||||||
|
|
||||||
// Health check with basic system info
|
// Health check with basic system info
|
||||||
app.get('/health', async (req, res) => {
|
app.get('/health', async (req, res) => {
|
||||||
const dbStatus = mongoose.connection.readyState === 1 ? 'connected' : 'disconnected';
|
const dbStatus = mongoose.connection.readyState === 1 ? 'connected' : 'disconnected';
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue