-
Notifications
You must be signed in to change notification settings - Fork 155
Add additional logging to troubleshoot failed backchannel logout issu… #632
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
77eceaa
a537b2f
c1fe376
3585c38
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -454,6 +454,7 @@ class ResponseContext { | |||||
| res.setHeader('cache-control', 'no-store'); | ||||||
| const logoutToken = req.body.logout_token; | ||||||
| if (!logoutToken) { | ||||||
| debug('req.oidc.backchannelLogout() failed due to missing logout token', req.body); | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Logging the entire
Suggested change
|
||||||
| res.status(400).json({ | ||||||
| error: 'invalid_request', | ||||||
| error_description: 'Missing logout_token', | ||||||
|
|
@@ -474,6 +475,7 @@ class ResponseContext { | |||||
| algorithms: [config.idTokenSigningAlg], | ||||||
| }); | ||||||
| } catch (e) { | ||||||
| debug('req.oidc.backchannelLogout() failed verifying jwt with: %s', e.message); | ||||||
| res.status(400).json({ | ||||||
| error: 'invalid_request', | ||||||
| error_description: e.message, | ||||||
|
|
@@ -483,7 +485,7 @@ class ResponseContext { | |||||
| try { | ||||||
| await onToken(token, config); | ||||||
| } catch (e) { | ||||||
| debug('req.oidc.backchannelLogout() failed with: %s', e.message); | ||||||
| debug('req.oidc.backchannelLogout() failed logging out the token with: %s', e.message); | ||||||
| res.status(400).json({ | ||||||
| error: 'application_error', | ||||||
| error_description: `The application failed to invalidate the session.`, | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -22,7 +22,7 @@ const enforceLeadingSlash = (path) => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const auth = function (params) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const config = getConfig(params); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| debug('configuration object processed, resulting configuration: %O', config); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| debug('configuration object processed, resulting configuration: %O', {...config, clientSecret: "REDACTED", secret: "REDACTED"}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| debug('configuration object processed, resulting configuration: %O', {...config, clientSecret: "REDACTED", secret: "REDACTED"}); | |
| const redactSensitiveFields = (obj, fieldsToRedact) => { | |
| if (obj && typeof obj === 'object') { | |
| return Object.keys(obj).reduce((acc, key) => { | |
| acc[key] = fieldsToRedact.includes(key) | |
| ? "REDACTED" | |
| : redactSensitiveFields(obj[key], fieldsToRedact); | |
| return acc; | |
| }, Array.isArray(obj) ? [] : {}); | |
| } | |
| return obj; | |
| }; | |
| const redactedConfig = redactSensitiveFields(config, ['clientSecret', 'secret']); | |
| debug('configuration object processed, resulting configuration: %O', redactedConfig); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The spread operator approach only handles top-level properties. If the config object contains nested objects with sensitive fields, they won't be redacted. Consider using a recursive redaction function to handle nested sensitive data.
| debug('configuration object processed, resulting configuration: %O', {...config, clientSecret: "REDACTED", secret: "REDACTED"}); | |
| const redactSensitiveFields = (obj) => { | |
| if (!obj || typeof obj !== 'object') return obj; | |
| const result = Array.isArray(obj) ? [...obj] : { ...obj }; | |
| Object.keys(result).forEach(key => { | |
| if (['clientSecret', 'secret'].includes(key)) { | |
| result[key] = 'REDACTED'; | |
| } else if (typeof result[key] === 'object') { | |
| result[key] = redactSensitiveFields(result[key]); | |
| } | |
| }); | |
| return result; | |
| }; | |
| debug('configuration object processed, resulting configuration: %O', redactSensitiveFields(config)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logging the entire req.body could potentially expose sensitive information. Consider logging only non-sensitive fields or a sanitized version of the request body.