CW-2776_Issue_with_casserver_and_service_urls_with_module.php_in_path#65
Conversation
…gin tests accordingly
Codecov Report✅ All modified and coverable lines are covered by tests. 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:
|
| // Construct the ReturnTo URL | ||
| return $this->httpUtils->getSelfURLNoQuery() . '?' . http_build_query($query); | ||
| $returnToBase = Module::getModuleURL('casserver/login'); | ||
| return $returnToBase . '?' . http_build_query($query); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
@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-ignoredAll 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.
There was a problem hiding this comment.
@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 ?
There was a problem hiding this comment.
@tvdijen i found the underlying issue. I will provide more details tomorrow and then we can decide on the best next steps.
There was a problem hiding this comment.
@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.
No description provided.