Add verbosity to missing auth headers error
This commit is contained in:
@@ -99,11 +99,26 @@ export const apiKeyAuthMacro = new Elysia().macro({
|
|||||||
const nonce = headers['x-nonce']
|
const nonce = headers['x-nonce']
|
||||||
const signature = headers['x-signature']
|
const signature = headers['x-signature']
|
||||||
const rawTimestamp = headers['x-timestamp']
|
const rawTimestamp = headers['x-timestamp']
|
||||||
if (!apiKey || !nonce || !signature || !rawTimestamp) {
|
|
||||||
|
const missingHeaders = []
|
||||||
|
if (!apiKey) {
|
||||||
|
missingHeaders.push('X-API-Key')
|
||||||
|
}
|
||||||
|
if (!nonce) {
|
||||||
|
missingHeaders.push('X-Nonce')
|
||||||
|
}
|
||||||
|
if (!rawTimestamp) {
|
||||||
|
missingHeaders.push('X-Timestamp')
|
||||||
|
}
|
||||||
|
if (!signature) {
|
||||||
|
missingHeaders.push('X-Signature')
|
||||||
|
}
|
||||||
|
if (missingHeaders.length) {
|
||||||
|
const missing = missingHeaders.join(', ')
|
||||||
logger.debug({
|
logger.debug({
|
||||||
'headers.authorization': headers.authorization,
|
'headers.authorization': headers.authorization,
|
||||||
}, 'Failed API key authentication attempt due to missing auth headers')
|
}, 'Failed API key authentication attempt due to missing auth headers: ' + missing)
|
||||||
throw new UnauthenticatedError('Missing auth headers')
|
throw new UnauthenticatedError('Missing auth headers: ' + missing)
|
||||||
}
|
}
|
||||||
|
|
||||||
const timestamp = Number(rawTimestamp)
|
const timestamp = Number(rawTimestamp)
|
||||||
|
|||||||
Reference in New Issue
Block a user