Drupal Version
10.4.*
Domain module version
2.0.0-beta2
Expected Behavior
The README file of Domain source states:
Domain Source changes core's `redirect_response_subscriber` service to the `DomainSourceRedirectResponseSubscriber` class. This allows us to issue redirects to registered domains and aliases that would otherwise not be recognizes as internal Drupal links. These redirects typically occur on entity save when the source domain varies from the current domain.
Actual Behavior
The service replacement is not made at all. Moreover, the event subscriber is clearly not up to date with the redirect_response_subscriber service. It should not copy the code from this service, as it will probably continue to evolve, but try to do as least as possible and rely on the parent method.
When requesting an URL for a page which source is defined to another domain, the user is not redirected to the correct domain
Steps to reproduce
Install Domain and Domain source
- Create 2 domains, "A" and "B"
- Make the login form
- Make the "page" content type using the domain source field
- Create a route related to domain "A" with role restrictions for example
- Create a subscriber which extends "HttpExceptionSubscriberBase" and override the on403 method to redirect to user login
- Make the login page allowed only for the "B" domain
The expected behavior is to have the user redirected from the A domain to the user login page on the "B" domain.
Instead we have an error page because the "redirect_response_subscriber" does not find a secured response.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | domain-fix-replacement-of-redirect_response_subscriber-service-3517215-3.patch | 5.48 KB | b-prod |
Issue fork domain-3517215
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3517215-the-replacement-of
changes, plain diff MR !197
- 2.0.x
changes, plain diff MR !196
Comments
Comment #2
b-prod commentedComment #3
b-prod commentedThe provided patch makes the "redirect_response_subscriber" to be replaced as expected, and simplify the code of the domain source event subscriber, so it relies more closely on its parent without duplicating the code.
Comment #4
mably commentedCould you create a merge-request please?
And it could be interesting to have a functional test to cover that problem.
Comment #6
ben.hamelinThanks @b-prod for opening this issue. Confirming the patch you provided worked for me.
@mably Opened the issue branch and am doing some further testing and development. I will open the MR soon hopefully!
Comment #7
mably commentedIs it still a problem? Could we have a MR please?
Comment #11
mably commentedMR created. Please review.
We also need a test for this.
Comment #12
mably commentedComment #13
mably commentedWhy is it done in the
domain_sourcesubmodule and not in the maindomainmodule?I do not see any reference to some
domain_sourcespecific code in theDomainSourceRedirectResponseSubscriberclass.Does your use case require the activation of the
domain_sourcemodule?If not, this should definitely be moved to the
domainmodule. Will work on it.Comment #14
mably commentedHad to add back some duplicated code from the
RedirectResponseSubscriberclass to properly handle theInvalidArgumentExceptionthat generates the status400message.Comment #15
mably commentedWould be great to have more detailed instructions to help reproduce the problem.
Comment #16
mably commentedI recommend enabling our domain-aware
RedirectResponseSubscriberby default to prevent potential issues with custom cross-domain redirects.MR code has been updated accordingly.
Comment #17
ben.hamelin@mably - I agree with the approach here to move this from domain_source into domain.
Patch applies cleanly to drupal/domain (dev-2.0.x c210cf8)
I am able to add a redirect to a local domain managed by domain module.
I think this is good to go
Comment #18
mably commentedAdded a functional test:
We should be ready to go.
Comment #20
mably commented