Skip to content

Commit

Permalink
Fix Max recursion error in WordPress 4.7
Browse files Browse the repository at this point in the history
Solve #44
  • Loading branch information
Tmeister committed Dec 7, 2016
1 parent 86d2dc9 commit 27305a2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion jwt-auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Plugin Name: JWT Authentication for WP-API
* Plugin URI: https://enriquechavez.co
* Description: Extends the WP REST API using JSON Web Tokens Authentication as an authentication method.
* Version: 1.2.2
* Version: 1.2.3
* Author: Enrique Chavez
* Author URI: https://enriquechavez.co
* License: GPL-2.0+
Expand Down
15 changes: 14 additions & 1 deletion public/class-jwt-auth-public.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,19 @@ public function generate_token($request)
*/
public function determine_current_user($user)
{
/**
* This hook only should run on the REST API requests to determine
* if the user in the Token (if any) is valid, for any other
* normal call ex. wp-admin/.* return the user.
*
* @since 1.2.3
**/
$rest_api_slug = rest_get_url_prefix();
$valid_api_uri = strpos($_SERVER['REQUEST_URI'], $rest_api_slug);
if(!$valid_api_uri){
return $user;
}

/*
* if the request URI is for validate the token don't do anything,
* this avoid double calls to the validate_token function.
Expand Down Expand Up @@ -220,7 +233,7 @@ public function validate_token($output = true)
if (!$auth) {
$auth = isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION']) ? $_SERVER['REDIRECT_HTTP_AUTHORIZATION'] : false;
}

if (!$auth) {
return new WP_Error(
'jwt_auth_no_auth_header',
Expand Down
9 changes: 6 additions & 3 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Contributors: tmeister
Donate link: https://enriquechavez.co
Tags: wp-json, jwt, json web authentication, wp-api
Requires at least: 4.2
Tested up to: 4.6.1
Stable tag: 1.2.2
Tested up to: 4.7
Stable tag: 1.2.3
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -340,7 +340,10 @@ $data = array(
###Please read how to configured the plugin https://wordpress.org/plugins/jwt-authentication-for-wp-rest-api/

== Changelog ==
= 1.2.1 =
= 1.2.3 =
* Fix Max recursion error in WordPress 4.7 #44

= 1.2.2 =
* Add an extra validation to get the Authorization header
* Increase determine_current_user priority Fix #13
* Add the user object as parameter in the jwt_auth_token_before_sign hook
Expand Down

0 comments on commit 27305a2

Please sign in to comment.