Skip to content

Commit

Permalink
Add a wrapper namespace to prevent conflicts with other plugins using…
Browse files Browse the repository at this point in the history
… the same JWT library
  • Loading branch information
Tmeister committed Oct 14, 2022
1 parent e334037 commit e386725
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 16 deletions.
7 changes: 4 additions & 3 deletions includes/class-jwt-auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,11 @@ private function load_dependencies() {
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-jwt-auth-i18n.php';

/**
* The class responsible for creating a unique namespace to load the JWT & Key
* classes of this plugin
* 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/extend-classes.php';
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
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 {
}
11 changes: 0 additions & 11 deletions includes/extend-classes.php

This file was deleted.

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
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 e386725

Please sign in to comment.