Opened 12 years ago
Last modified 6 weeks ago
#28212 new defect (bug)
determine_current_user filter with priority <10 gets overridden
| Reported by: | rmccue | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Login and Registration | Version: | 3.9 |
| Severity: | normal | Keywords: | needs-testing has-patch has-unit-tests |
| Cc: | Focuses: | rest-api |
Description
Introduced in #26706.
wp_validate_auth_cookie was shoehorned into this filter, and as such, doesn't return what the filter expects. On any error at all, it returns false, even if the "error" is that the cookie isn't set. If a function hooked into a lower priority (i.e. <10) returns a user ID, this will then be overridden by the built-in auth cookie.
Attachments (2)
Change History (10)
#3
@
11 years ago
It appears that #26706 had some extra code. It added two filters. The first callable doesn't take in and output the user id, but cookie info. The second callable uses the function from first addition correctly.
#4
@
11 years ago
There's an additional condition with a lower priority being ignored if it determines that there should not be a user. With the following filter added, you can still be logged in.
add_filter( 'determine_current_user', function ( $user ) {
return 0;
}, 0 );
#5
@
8 years ago
- Component Users → REST API
- Keywords needs-testing needs-refresh added
I'm moving this old ticket into the REST API component on the basis that fixing this would be necessary for alternative authentication. If a client is setting credentials be it basic auth, a bearer token, what have you, that should go before cookie authentication.
This ticket was mentioned in Slack in #core-restapi by timothybjacobs. View the logs.
7 years ago
This ticket was mentioned in PR #12789 on WordPress/wordpress-develop by @abcd95.
6 weeks ago
#8
- Keywords has-patch has-unit-tests added; needs-refresh removed
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Oh, and to reproduce:
add_filter( 'determine_current_user', function ( $user ) { return 1; }, 0 );Expected result: Always logged in as user 1.
Actual result: Still uses cookie authentication.