- π¨π¦Canada joelpittet Vancouver
I'm re-opening as it's still an issue, even for non
base_path
sites it ends up with 2 slashes after login.samlauth/src/Controller/SamlController.php:342
SamlController::getUrlFromDestination
We workaround it currently by embedding a destination parameter and strip
base_path
and leading slash as this is what SAMLauth expects and appendsbase_url
in our login link:// Strip base_path and leading slash as this is what SAMLauth expects // and appends base_url. // @see samlauth/src/Controller/SamlController.php:342 $destination = \Drupal::destination()->get(); $destination = preg_replace('#^' . $GLOBALS['base_path'] . '#', '', $destination); $form['actions']['submit'] = [ '#type' => 'link', '#title' => $this->t('SAML Login'), '#url' => Url::fromRoute('samlauth.saml_controller_login'), '#options' => [ 'query' => ['destination' => $destination], ], ];
- π¨π¦Canada joelpittet Vancouver
I just realized this was fixed on the 2.x branch but it is broken on the 3.x branch.
https://git.drupalcode.org/issue/samlauth-2939159/-/blob/2939159-redirec...
#2670118: Make getPostLoginDestination / getPostLogoutDestination configurable β
#3041903: Issues with destination parameter β - π¨π¦Canada joelpittet Vancouver
Attached is a debug step through of the proposed change in action.
- Merge request !17Build absolute URL from user input to encoporate base_path β (Merged) created by joelpittet
- last update
about 1 year ago 4 pass - πΊπΈUnited States timwood Rockville, Maryland
We just recently started encountering the double leading slash issue that @joelpittet mentions above. We use SAMLAuth along with the https://www.drupal.org/project/require_login β module to force all visitors to login to our Intranet.
- π¨π¦Canada joelpittet Vancouver
My MR above had a side-effect, apparently there are cases where the URL is missing the first slash resulting in:
CRITICAL Message: InvalidArgumentException encountered while initiating SAML login: The user-entered string 'home' must begin with a '/', '?', or '#'. in Drupal\Core\Url::fromUserInput() (line 216 of core/lib/Drupal/Core/Url.php). Time: 2023-10-26T12:31:32.458774-07:00 Channel: samlauth Context: exception: { "class": "InvalidArgumentException", "message": "The user-entered string 'home' must begin with a '/', '?', or '#'.", "code": 0, "file": "core/lib/Drupal/Core/Url.php:216", "trace": [...
I'll update the code to mitigate against that possibility (though it might be on our end).
- last update
about 1 year ago 4 pass - π¨π¦Canada joelpittet Vancouver
I added the
ltrim()
that core uses in various partsSee prior art:
core/lib/Drupal/Core/Form/ConfirmFormHelper.php core/modules/migrate/src/Plugin/migrate/process/MenuLinkParent.php core/modules/views/src/Plugin/views/display/DisplayPluginBase.php core/modules/views/src/Plugin/views/field/FieldPluginBase.php
- Status changed to Needs work
about 1 year ago 7:07am 3 November 2023 - πΊπΈUnited States timwood Rockville, Maryland
Any ideas on how to move this forward? It's more of a nuisance, but is still there, lingering...
- π¨π¦Canada joelpittet Vancouver
Sorry @timwood, I haven't got a chance to dig into what went wrong with my last MR.
- π¨π¦Canada joelpittet Vancouver
Adding another related issue #2418219: Deprecate destination URLs that don't include the base path β as I dig into this further. Specifically #2418219-22: Deprecate destination URLs that don't include the base path β from @claudiu.cristea
Or better keep the current behavior: if the destination starts with a slash, it has the base path prefix. No slash, it's the internal path or alias.
- Open on Drupal.org βCore: 9.5.5 + Environment: PHP 7.4 & MySQL 5.7last update
7 months ago Waiting for branch to pass - Status changed to Needs review
7 months ago 4:40pm 16 May 2024 - π¨π¦Canada joelpittet Vancouver
@timwood This latest solution seems to check all the boxes. I check if there is a base_path and strip it out only when the destination URL is starts with a starting / (which might be always), then the full URL built has a base_path included (can't seem to get around this without manually building it)
- Open on Drupal.org βCore: 9.5.5 + Environment: PHP 7.4 & MySQL 5.7last update
6 months ago Waiting for branch to pass - Status changed to RTBC
6 months ago 4:29pm 3 July 2024 - πΊπΈUnited States timwood Rockville, Maryland
Applied patch and ran login / logout tests with many different urls and the patch seems to be working correctly without adding any errors or issues.
- First commit to issue fork.
-
japerry β
committed b938d0c5 on 8.x-3.x authored by
joelpittet β
Issue #2939159 by geertvd: Redirect after login not correct when using...
-
japerry β
committed b938d0c5 on 8.x-3.x authored by
joelpittet β
- Status changed to Fixed
6 months ago 4:47am 10 July 2024 Automatically closed - issue fixed for 2 weeks with no activity.