Opened 3 months ago
Closed 3 months ago
#62881 closed defect (bug) (fixed)
Strict referrer policy is breaking post/page passwords
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 6.8 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Posts, Post Types | Keywords: | good-first-bug has-patch |
Focuses: | Cc: |
Description
I hoped #62273 could have fixed this problem, but @johnbillion said this is not the case and asked me to open a new ticket here. So, here it is:
If we password protect a post or page the password gets send to /wp-login.php?action=postpass
The code can be seen on this link:
https://github.com/WordPress/WordPress/blob/master/wp-login.php#L766-L797
The problem is now this line:
wp_safe_redirect( wp_get_referer() );
If no referrer is there (or only the domain, but no path) the redirect is not working at all (White Screen of Death) or after entering the password you get redirected to the domain instead of the post/page (although the postpass cookie is now there and access is granted, you need to find the page again).
This bug was first reported in the forums:
https://wordpress.org/support/topic/password-protected-page-no-longer-working/
Relevant documentation can be found here:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy
On Apache you can disable the referrer with these lines:
# Referrer-Policy <IfModule mod_headers.c> Header set Referrer-Policy "no-referrer" </IfModule>
or set to only send the domain (no path):
# Referrer-Policy <IfModule mod_headers.c> Header set Referrer-Policy "origin" </IfModule>
The suggested solution from @johnbillion in #62273 was this idea:
Seem like it would be easily solved by adding hidden redirect_to field in get_the_password_form().
Change History (5)
#1
@
3 months ago
- Keywords good-first-bug added
- Milestone changed from Awaiting Review to Future Release
This ticket was mentioned in PR #8220 on WordPress/wordpress-develop by @yogeshbhutkar.
3 months ago
#3
- Keywords has-patch added; needs-patch removed
### Description
Adds a hidden
redirect_to
field to the password protection form to ensure proper redirection when Referrer-Policy is set to 'no-referrer'. This fixes the issue where users would see a white screen or get redirected to the homepage after entering a correct password.Previously, the redirect relied solely on
wp_get_referer()
which fails when:### Testing Instructions
Trac ticket: https://core.trac.wordpress.org/ticket/62881