-
Notifications
You must be signed in to change notification settings - Fork 29.1k
Description
Verify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
n/a
Originates in recommendations within documentation, and results in the "working" but potentially-insecure implementation of those recommendations.
Which example does this report relate to?
cms-wordpress
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
The example circumvents pre-existing security/authorization controls implemented within WordPress core. Users should be able to reasonably expect that a Next.js-based implementation of post previews provides the same level of security and access control as that of WordPress core.
Additionally relevant: #29877 was closed and locked without providing any explanation as to the verification process. How was the verified reproduction performed?
The response is somewhat alarming considering the prominence of the cms-wordpress
example, however the unceremonious closure and locking of #29877 results in the flagged misuse of WordPress authentication being buried without context, forcing the original commenter's concerns to go unaddressed, and allowing the potential issues in the example to proliferate.
Expected Behavior
The official example should provide a gold standard baseline for Next.js integration with WordPress, especially with regard to authenticated post previews, as at the time of writing, the WordPress+Next.js ecosystem is populated by numerous differing implementations of post preview functionality over the years, and it would be very much appreciated if Next.js provided an example implementation using authentication best-practices.
For example, an approach leveraging per-user WordPress Application Passwords.
To Reproduce
See #29877 –
Or, roughly:
- Follow the guide for setting up post previews.
- As an Administrator user, create a test post without publishing (save as draft)
- Copy the post preview URL and open in a private browser session: the post should not be visible without authentication according to WordPress core user permissions
- Create a new WordPress user with a lower-privileged Role like "Contributor", which does not have the ability to view, edit, or manage anyone's posts except for their own
- Log in as the new user in a private browser session
- Go to the preview URL for the unpublished post created by the Administrator user – it should not be accessible