collect loggable data before authentication. fixes #601

This commit is contained in:
Danny Coates 2014-02-28 18:25:12 -08:00
Родитель 3e9fa74260
Коммит db8695ff35
1 изменённых файлов: 12 добавлений и 30 удалений

Просмотреть файл

@ -140,27 +140,8 @@ module.exports = function (path, url, Hapi, toobusy) {
}
)
// Log some helpful details for debugging authentication problems.
server.ext(
'onPreAuth',
function (request, next) {
if (request.headers.authorization) {
log.trace(
{
op: 'server.onPreAuth',
rid: request.id,
path: request.path,
auth: request.headers.authorization,
type: request.headers['content-type'] || ''
}
)
}
next()
}
)
server.ext(
'onPreHandler',
function (request, next) {
// Construct source-ip-address chain for logging.
var xff = (request.headers['x-forwarded-for'] || '').split(/\s*,\s*/)
@ -174,17 +155,18 @@ module.exports = function (path, url, Hapi, toobusy) {
var accepted = i18n.parseAcceptLanguage(acceptLanguage)
request.app.preferredLang = i18n.bestLanguage(accepted)
}
if (request.headers.authorization) {
// Log some helpful details for debugging authentication problems.
log.trace(
{
op: 'server.onPreHandler',
op: 'server.onPreAuth',
rid: request.id,
path: request.path,
auth: request.auth.isAuthenticated,
uid: request.auth.credentials ? request.auth.credentials.uid : null,
payload: request.payload
auth: request.headers.authorization,
type: request.headers['content-type'] || ''
}
)
}
next()
}
)