verbb / knock-knock

Password protect your entire Craft website front-end with a single password
MIT License
18 stars 7 forks source link

Plugin is forcing a redirect to base URI for site #43

Open JonGoldmanPlaybill opened 3 years ago

JonGoldmanPlaybill commented 3 years ago

I have a site that responds to multiple subdomains within the same site (e.g., domain.com, sub1.domain.com, sub2.domain.com, etc.). When I enable knock-knock every request is redirected to domain.com

In the protected URLs I have the following entries:

I'm not using a config file, but it is my understanding that the forced redirect is not supposed to take effect unless I enable it with a config php file manually.

Can you explain this behavior?

engram-design commented 3 years ago

Hmmm, so it should be taking into account the referrer URL and redirect based on that. I'll double check this for multi-site situations. It might be that it can't detect (properly) the site you're trying to access.

You shouldn't need a config file for the most part, and the forcedRedirect is really there as an override to redirect to. This wouldn't be what you'd want in your case, as it would redirect everything to a single static URL, which is what's happening.

And just to clarify, when you mention it's redirected to domain.com - is that to enter the password to access the site, or after entering in the password to access the site, you're afterwards redirected to domain.com (despite accessing from a subdomain, etc)

JonGoldmanPlaybill commented 3 years ago

@engram-design It is redirecting for both. Note that I do not use multi-site in Craft 3, I am simply allowing multiple subdomains to come into the same site. So I believe it is using the default URL from the .env file instead of the actual referring URL.

engram-design commented 3 years ago

Gotcha. I've fixed the referrer redirect issue.

The only issue with this is that it's a little more complicated for multiple domains. We would need to change the mechanism for remembering that you've logged in successfully across multiple subdomains, which I'll need to look into. Right now, even with this fix, you'll be redirected correctly after logging in, but it'll prompt you to login again, as it won't have remembered you on the subdomains.

engram-design commented 3 years ago

Fixed the referrer issue in 1.2.15

jan-dh commented 6 days ago

@engram-design what would be the right approach for multiple domains? I have a multi-site setup with sitegroup 1 - 8 sites on 1 domain, sitegroup 2: 4 sites on a second domain; can't seem to get knock-knock to work cross domain atm.