mirror of
https://github.com/koala73/worldmonitor.git
synced 2026-04-25 17:14:57 +02:00
debug(auth): expose full key comparison detail in Invalid API key 401 (#2313)
This commit is contained in:
@@ -52,8 +52,18 @@ export function validateApiKey(req, options = {}) {
|
||||
return { valid: false, required: true, error: 'API key required' };
|
||||
}
|
||||
if (key) {
|
||||
const validKeys = (process.env.WORLDMONITOR_VALID_KEYS || '').split(',').filter(Boolean);
|
||||
if (!validKeys.includes(key)) return { valid: false, required: true, error: 'Invalid API key' };
|
||||
const rawEnv = process.env.WORLDMONITOR_VALID_KEYS || '';
|
||||
const validKeys = rawEnv.split(',').filter(Boolean);
|
||||
if (!validKeys.includes(key)) return {
|
||||
valid: false, required: true, error: 'Invalid API key',
|
||||
_debug: {
|
||||
receivedKey: key,
|
||||
receivedKeyLen: key.length,
|
||||
envVarRaw: rawEnv,
|
||||
parsedKeys: validKeys,
|
||||
envVarLen: rawEnv.length,
|
||||
},
|
||||
};
|
||||
}
|
||||
return { valid: true, required: forceKey };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user