#2143 - Enforce correct access protocol (HTTP vs HTTPS)
| Identifier | #2143 |
|---|---|
| Issue type | Feature request or suggestion |
| Title | Enforce correct access protocol (HTTP vs HTTPS) |
| Status | Completed |
| Tags |
Good for training (custom) Roadmap: v11 (custom) |
| Handling member | Chris Graham |
| Addon | core |
| Description | If a base URL / page specifies HTTPS, and you access with HTTP, handle this with a redirect, just like as if you didn't use the correct URL scheme.
Also HTTPS to HTTP, just in case caching creates issues if the wrong protocol is used. |
| Steps to reproduce | |
| Funded? | No |
The system will post a comment when this issue is modified (e.g., status changes). To be notified of this, click "Enable comment notifications".


Comments
Needs thought.
The option would define a list of situations to do redirects, e.g. 'protocol,domain'.
So .htaccess equivalents may still be needed, and we need to think how we should handle that - maybe through documentation under static caching.
Complicating factors resolved as follows:
1) What if we're behind a proxy and therefore cannot detect if SSL is being used in a normal way? We respect the 'X-Forwarded-Proto' header and trust it only if we validate the proxy caller successfully.
2) What if a page needs to be accessed sometimes HTTPS and sometimes not? I don't think that's a real use case. The use case is some pages may be HTTPS and some not, as per the 'ssl' addon. We will do forwarding based on correct identifying of what the page should be, checking both the base URL and the SSL configuration for the page (if the 'ssl' addon is installed). We cannot use a URL flag, as the HTTP->HTTPS URL redirection is a security feature and we cannot trust the calling URL parameters.
3) What about the static cache? The redirection code now runs early, it is no longer in site.php. The only issue is that the SSL addon configuration cannot be respected, leading to no redirects for individually enabled SSL pages when served via static cache. This seems an insignificant corner case.
4) While 'Strict-Transport-Security' cannot be used, it is now documented that a user can enable it in their web config (including how).
5) Redirects may also happen due to CSP. This remains documented. We do not rely on it, as we should not assume every web client has CSP available (especially things like wget).
I have removed the hidden 'access_protocol_redirect' option as it is not needed, and use of that prevented us moving the redirection code out of site.php.