Skip to content

Commit 2cdbd55

Browse files
committed
Always verify the token, if provided
Per #5 (comment)
1 parent b25d117 commit 2cdbd55

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

wp-includes/rest-api/auth/class-wp-rest-token.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,11 @@ public function require_token() {
272272
$require_token = false;
273273
}
274274

275-
// GET requests do not require authentication, but if a valid token is provided, requests should
275+
// GET requests do not require authentication, but if
276+
// the Authorization header is provided, requests should
276277
// be performed as the user corresponding to that token.
277-
if ( 'GET' === $request_method && is_wp_error( $this->validate_token() ) ) {
278-
$require_token = false;
278+
if ( 'GET' === $request_method && ! is_wp_error( $this->get_auth_header() ) ) {
279+
$require_token = true;
279280
}
280281

281282
// Don't require authentication to generate a token.

0 commit comments

Comments
 (0)