Skip to content

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Preview

Copilot AI Jul 18, 2025

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.

Suggested change
debug('req.oidc.backchannelLogout() failed due to missing logout token', req.body);
debug('req.oidc.backchannelLogout() failed due to missing logout token. logout_token present: %s', !!req.body.logout_token);

Copilot uses AI. Check for mistakes.

res.status(400).json({
error: 'invalid_request',
error_description: 'Missing logout_token',
Expand All @@ -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,
Expand All @@ -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.`,
Expand Down
2 changes: 1 addition & 1 deletion middleware/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"});
Copy link
Preview

Copilot AI Jul 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spread operator approach may not handle nested objects containing sensitive data. Consider using a dedicated function to recursively redact sensitive fields or ensure no nested sensitive data exists in the config object.

Suggested change
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);

Copilot uses AI. Check for mistakes.

const router = new express.Router();
const transient = new TransientCookieHandler(config);

Expand Down