Skip to content

Conversation

@ioigoume
Copy link
Contributor

No description provided.

@codecov
Copy link

codecov bot commented Jan 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.05%. Comparing base (a711377) to head (4271f44).

Additional details and impacted files
@@                Coverage Diff                @@
##             release-7.0      #65      +/-   ##
=================================================
+ Coverage          68.03%   68.05%   +0.02%     
  Complexity           364      364              
=================================================
  Files                 25       25              
  Lines               1220     1221       +1     
=================================================
+ Hits                 830      831       +1     
  Misses               390      390              
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

// Construct the ReturnTo URL
return $this->httpUtils->getSelfURLNoQuery() . '?' . http_build_query($query);
$returnToBase = Module::getModuleURL('casserver/login');
return $returnToBase . '?' . http_build_query($query);
Copy link
Member

@tvdijen tvdijen Jan 26, 2026

Choose a reason for hiding this comment

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

This should be giving the exact same result?
If this is not the case, I think it might be better to rely on Symfony's request object and use $request->getBaseUrl() instead of our own http-utils

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tvdijen I’m looking into the issue. These are the values I get when I use each method:

----- request->getBaseUrl() ---- :   /simplesaml/module.php
----- Module::getModuleURL('casserver/login') ---- :   https://localhost/simplesaml/module.php/casserver/login
----- this->httpUtils->getSelfURLNoQuery() ---- :  https://localhost/simplesaml/module.php/this-should-be-ignored

All methods except Module::getModuleURL() return an incorrect value. It looks like the module.php segment in the path is being treated as the end of the URL, right before the query string should start.

Copy link
Member

Choose a reason for hiding this comment

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

@tvdijen I’m looking into the issue. These are the values I get when I use each method:

----- this->httpUtils->getSelfURLNoQuery() ---- :  https://localhost/simplesaml/module.php/this-should-be-ignored

Why do you feel that anything after module.php should be ignored? It's not part of the query, so it's still included in the self URL.. The query starts after the ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tvdijen i found the underlying issue. I will provide more details tomorrow and then we can decide on the best next steps.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tvdijen according to my findings the HTTP::getSelfURL() mis-reconstructs the current URL when SimpleSAMLphp is accessed through a rewritten path such as RewriteRule ^/cas/login(.*) /${SSP_APACHE_ALIAS}module.php/casserver/login.php$1 [PT]. In this scenario the public URL is /cas/login?service=..., while Apache internally rewrites it to /simplesaml/module.php/casserver/login.php?service=.... The old implementation assumes that the script-relative filesystem path (for example module.php/casserver/login.php) appears verbatim in $_SERVER['REQUEST_URI'], searches for that substring in the entire REQUEST_URI, and rebuilds the URL by stitching together getBaseURL(), that matched path, and the remainder of REQUEST_URI. With mod_rewrite, REQUEST_URI contains only the external path (/cas/login?...), so the expected script path is not present, or may only appear by accident inside query parameters. This causes getSelfURL() to either fall back to an incorrect URL or to construct one that points to module.php/... instead of /cas/login, or that has a malformed path/query combination, breaking redirects and return URLs that rely on getSelfURL() to reflect the actual public URL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants