Redirect does not work with base paths

Created on 24 July 2024, 9 months ago

When a site has a base path and the redirect comes from the 'destination' parameter in our URL queries the basepathis getting doubled

Login via
https://example.com/my-base-path/user/login/openid_connect?destination=/...

Will return to
https://example.com/my-base-path/my-base-path/home

Patch provided.

Notes about patch.
This module has code to strip out the '/' from the beginning of URLs, whether that is from the destination or from Url::fromRoute. I have opted to remove that (ie keep the '/') as it does not follow the examples I can find in Drupal Core (eg: Url::fromRoute, \Drupal::destination()->get()).

🐛 Bug report
Status

Active

Version

3.0

Component

Code

Created by

🇦🇺Australia au_dave Adelaide

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

Merge Requests

Comments & Activities

  • Issue created by @au_dave
  • 🇳🇱Netherlands Klaas Culemborg

    Hi @au_dave, thanks for the patch. I work fine on my drupal site.

  • First commit to issue fork.
  • Merge request !149Redirect does not work with base paths. → (Open) created by shivam_tiwari
  • Pipeline finished with Success
    about 2 months ago
    Total: 340s
    #447221
  • I was struggling to integrate this module with Anonymous Login and Redirect After Login in combination with the site being in a subdirectory. I also had to retain the prefixing "/" from the destination in the session, but came up with a slightly alternate approach in the redirect controller that let me seamlessly integrate with Redirect After Login by distinguishing between a user-provided destination and a default destination (to do this, I set this module's login destination to nothing / empty string).

    I previously put a comment on a Redirect After Login issue for compatibility with this module, which details more of the things I had to work through and why/how I came up with this solution, in case it's of interest/use: https://www.drupal.org/project/redirect_after_login/issues/3513324#comme... Improve compatibility with OpenID Connect destination Active .

    A potential benefit of this approach to set the destination in the query is that it doesn't require copying Drupal core code from RedirectResponseSubscriber (because it will be triggered by use of the query destination).

Production build 0.71.5 2024