Skip to content

Commit

Permalink
Merge pull request #253 from Tmeister/namespace-wrapper
Browse files Browse the repository at this point in the history
Fix conflicts with other plugins using the same JWT library adding a wrapper namespace to the JWT class.

Fix #247
  • Loading branch information
Tmeister authored Oct 17, 2022
2 parents a185018 + e386725 commit 225ca87
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 4 deletions.
7 changes: 7 additions & 0 deletions includes/class-jwt-auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ private function load_dependencies() {
*/
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-jwt-auth-i18n.php';

/**
* Class responsible for creating a `wrapper namespace` to load the Firebase's JWT & Key
* classes and prevent conflicts with other plugins using the same library
* with different versions.
*/
require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-jwt-namespace-wrapper.php';

/**
* The class responsible for defining all actions that occur in the public-facing
* side of the site.
Expand Down
18 changes: 18 additions & 0 deletions includes/class-jwt-namespace-wrapper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
/**
* Define a `wrapper namespace` to load the Firebase's JWT & Key classes
* and prevent conflicts with other plugins using the same library
* with different versions.
*
* @link https://enriquechavez.co
* @since 1.3.2
* @author marioshtika https://github.com/marioshtika
*/

namespace Tmeister\Firebase\JWT;

class JWT extends \Firebase\JWT\JWT {
}

class Key extends \Firebase\JWT\Key {
}
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.3.1
* Version: 1.3.2
* Author: Enrique Chavez
* Author URI: https://enriquechavez.co
* License: GPL-2.0+
Expand Down
4 changes: 2 additions & 2 deletions public/class-jwt-auth-public.php
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

/** Require the JWT library. */
use Firebase\JWT\JWT;
use Firebase\JWT\Key;
use Tmeister\Firebase\JWT\JWT;
use Tmeister\Firebase\JWT\Key;

/**
* The public-facing functionality of the plugin.
Expand Down
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Tags: wp-json, jwt, json web authentication, wp-api
Requires at least: 4.2
Tested up to: 6.0.2
Requires PHP: 7.4.0
Stable tag: 1.3.1
Stable tag: 1.3.2
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -365,6 +365,9 @@ I've created a small app to test the basic functionality of the plugin; you can
###Please read how to configured the plugin https://wordpress.org/plugins/jwt-authentication-for-wp-rest-api/

== Changelog ==
= 1.3.2 =
* Fix conflicts with other plugins using the same JWT library adding a wrapper namespace to the JWT class.

= 1.3.1 =
* Updating the minimum version of PHP to 7.4
* Validate the signing algorithm against the supported algorithms @see https://www.rfc-editor.org/rfc/rfc7518#section-3
Expand Down

0 comments on commit 225ca87

Please sign in to comment.