Cacheability Metadata Leakage Error on SAML Login with Samlauth and r4032 Redirect Module

Created on 12 November 2024, 3 months ago

Problem/Motivation

When using the samlauth module alongside the r4032login redirect module in Drupal, initiating a SAML login with a non-base path results in a cacheability metadata leakage warning.

Steps to reproduce

  • Install a standard Drupal core setup (v10.3).
  • Add the samlauth and r4032login modules.
  • Attempt to log in with a path other than the homepage where authentication is required for your site (e.g., 'mysite.test/node/1').

Error Message: The following error is produced during SAML login:

`While initiating SAML login, code leaked cacheability metadata. This indicates a bug somewhere (but it is hard to pinpoint where): if the same code is called in other scenarios too, it may cause fatal crashes, or bloat the render cache unnecessarily. Please investigate. Metadata: i:6;:O:37:"Drupal\Core\Render\BubbleableMetadata":4:{s:16:"*cacheContexts";a:1:{i:0;s:8:"url.site";}s:12:"*cacheTags";a:0:{}s:14:"*cacheMaxAge";i:-1;s:14:"*attachments";a:0:{}}`

Proposed resolution

This issue appeared after updating from the 8.x-3.9 to 8.x-3.10 branch, with the following commit as the identified cause. The error only occurs with this commit; without it, the leakage is not reproducible. Redirect after login not correct when using base_path (Issue #2939159)

This error suggests a bug within cacheability metadata handling in samlauth when a redirect path is involved.

🐛 Bug report
Status

Active

Version

3.10

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024