mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-08 00:08:14 +01:00
SSO/OpenID: Also Log token header
This commit is contained in:
parent
ad53894ea1
commit
618028503b
@ -363,10 +363,13 @@ class Auth {
|
|||||||
req.session[sessionKey].code_verifier = req.query.code_verifier
|
req.session[sessionKey].code_verifier = req.query.code_verifier
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleAuthError(isMobile, errorCode, errorMessage, logMessage, logMessageDetail) {
|
function handleAuthError(isMobile, errorCode, errorMessage, logMessage, response) {
|
||||||
Logger.error(logMessage)
|
Logger.error(logMessage)
|
||||||
if (logMessageDetail) {
|
if (response) {
|
||||||
Logger.debug(logMessageDetail.toString())
|
// Depending on the error, it can also have a body
|
||||||
|
// We also log the request header the passport plugin sents for the URL
|
||||||
|
const header = response.req?._header.replace(/Authorization: [^\r\n]*/i, 'Authorization: REDACTED')
|
||||||
|
Logger.debug(header + '\n' + response.body?.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isMobile) {
|
if (isMobile) {
|
||||||
@ -380,13 +383,12 @@ class Auth {
|
|||||||
return (err, user, info) => {
|
return (err, user, info) => {
|
||||||
const isMobile = req.session[sessionKey]?.mobile === true
|
const isMobile = req.session[sessionKey]?.mobile === true
|
||||||
if (err) {
|
if (err) {
|
||||||
return handleAuthError(isMobile, 500, 'Error in callback', `[Auth] Error in openid callback - ${err}`, err?.response?.body)
|
return handleAuthError(isMobile, 500, 'Error in callback', `[Auth] Error in openid callback - ${err}`, err?.response)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
// Info usually contains the error message from the SSO provider
|
// Info usually contains the error message from the SSO provider
|
||||||
// Depending on the error, it can also have a body
|
return handleAuthError(isMobile, 401, 'Unauthorized', `[Auth] No user in openid callback - ${info}`, info?.response)
|
||||||
return handleAuthError(isMobile, 401, 'Unauthorized', `[Auth] No user in openid callback - ${info}`, info?.response?.body)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
req.logIn(user, (loginError) => {
|
req.logIn(user, (loginError) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user