-
-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Plugin basic structure - Added new login route to the API - Added Firebase/jwt-auth
- Loading branch information
0 parents
commit dc20a91
Showing
48 changed files
with
2,873 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# JSON Web Token Authentication for WP-API | ||
Add the ability to authenticate the API calls using JWT to the WP-API | ||
|
||
## Work in Progress incomplete development |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
<?php | ||
|
||
/** | ||
* The admin-specific functionality of the plugin. | ||
* | ||
* @link https://enriquechavez.co | ||
* @since 1.0.0 | ||
* | ||
* @package Jwt_Auth | ||
* @subpackage Jwt_Auth/admin | ||
*/ | ||
|
||
/** | ||
* The admin-specific functionality of the plugin. | ||
* | ||
* Defines the plugin name, version, and two examples hooks for how to | ||
* enqueue the admin-specific stylesheet and JavaScript. | ||
* | ||
* @package Jwt_Auth | ||
* @subpackage Jwt_Auth/admin | ||
* @author Enrique Chavez <[email protected]> | ||
*/ | ||
class Jwt_Auth_Admin { | ||
|
||
/** | ||
* The ID of this plugin. | ||
* | ||
* @since 1.0.0 | ||
* @access private | ||
* @var string $plugin_name The ID of this plugin. | ||
*/ | ||
private $plugin_name; | ||
|
||
/** | ||
* The version of this plugin. | ||
* | ||
* @since 1.0.0 | ||
* @access private | ||
* @var string $version The current version of this plugin. | ||
*/ | ||
private $version; | ||
|
||
/** | ||
* Initialize the class and set its properties. | ||
* | ||
* @since 1.0.0 | ||
* @param string $plugin_name The name of this plugin. | ||
* @param string $version The version of this plugin. | ||
*/ | ||
public function __construct( $plugin_name, $version ) { | ||
|
||
$this->plugin_name = $plugin_name; | ||
$this->version = $version; | ||
|
||
} | ||
|
||
/** | ||
* Register the stylesheets for the admin area. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
public function enqueue_styles() { | ||
|
||
/** | ||
* This function is provided for demonstration purposes only. | ||
* | ||
* An instance of this class should be passed to the run() function | ||
* defined in Jwt_Auth_Loader as all of the hooks are defined | ||
* in that particular class. | ||
* | ||
* The Jwt_Auth_Loader will then create the relationship | ||
* between the defined hooks and the functions defined in this | ||
* class. | ||
*/ | ||
|
||
wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/jwt-auth-admin.css', array(), $this->version, 'all' ); | ||
|
||
} | ||
|
||
/** | ||
* Register the JavaScript for the admin area. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
public function enqueue_scripts() { | ||
|
||
/** | ||
* This function is provided for demonstration purposes only. | ||
* | ||
* An instance of this class should be passed to the run() function | ||
* defined in Jwt_Auth_Loader as all of the hooks are defined | ||
* in that particular class. | ||
* | ||
* The Jwt_Auth_Loader will then create the relationship | ||
* between the defined hooks and the functions defined in this | ||
* class. | ||
*/ | ||
|
||
wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/jwt-auth-admin.js', array( 'jquery' ), $this->version, false ); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/** | ||
* All of the CSS for your admin-specific functionality should be | ||
* included in this file. | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?php // Silence is golden |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
(function( $ ) { | ||
'use strict'; | ||
|
||
/** | ||
* All of the code for your admin-specific JavaScript source | ||
* should reside in this file. | ||
* | ||
* Note that this assume you're going to use jQuery, so it prepares | ||
* the $ function reference to be used within the scope of this | ||
* function. | ||
* | ||
* From here, you're able to define handlers for when the DOM is | ||
* ready: | ||
* | ||
* $(function() { | ||
* | ||
* }); | ||
* | ||
* Or when the window is loaded: | ||
* | ||
* $( window ).load(function() { | ||
* | ||
* }); | ||
* | ||
* ...and so on. | ||
* | ||
* Remember that ideally, we should not attach any more than a single DOM-ready or window-load handler | ||
* for any particular page. Though other scripts in WordPress core, other plugins, and other themes may | ||
* be doing this, we should try to minimize doing that in our own work. | ||
*/ | ||
|
||
})( jQuery ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
/** | ||
* Provide a admin area view for the plugin | ||
* | ||
* This file is used to markup the admin-facing aspects of the plugin. | ||
* | ||
* @link https://enriquechavez.co | ||
* @since 1.0.0 | ||
* | ||
* @package Jwt_Auth | ||
* @subpackage Jwt_Auth/admin/partials | ||
*/ | ||
?> | ||
|
||
<!-- This file should primarily consist of HTML with a little bit of PHP. --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"config": { | ||
"vendor-dir": "includes/vendor" | ||
}, | ||
"require": { | ||
"firebase/php-jwt": "^3.0" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
/** | ||
* Fired during plugin activation | ||
* | ||
* @link https://enriquechavez.co | ||
* @since 1.0.0 | ||
* | ||
* @package Jwt_Auth | ||
* @subpackage Jwt_Auth/includes | ||
*/ | ||
|
||
/** | ||
* Fired during plugin activation. | ||
* | ||
* This class defines all code necessary to run during the plugin's activation. | ||
* | ||
* @since 1.0.0 | ||
* @package Jwt_Auth | ||
* @subpackage Jwt_Auth/includes | ||
* @author Enrique Chavez <[email protected]> | ||
*/ | ||
class Jwt_Auth_Activator { | ||
|
||
/** | ||
* Short Description. (use period) | ||
* | ||
* Long Description. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
public static function activate() { | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
/** | ||
* Fired during plugin deactivation | ||
* | ||
* @link https://enriquechavez.co | ||
* @since 1.0.0 | ||
* | ||
* @package Jwt_Auth | ||
* @subpackage Jwt_Auth/includes | ||
*/ | ||
|
||
/** | ||
* Fired during plugin deactivation. | ||
* | ||
* This class defines all code necessary to run during the plugin's deactivation. | ||
* | ||
* @since 1.0.0 | ||
* @package Jwt_Auth | ||
* @subpackage Jwt_Auth/includes | ||
* @author Enrique Chavez <[email protected]> | ||
*/ | ||
class Jwt_Auth_Deactivator { | ||
|
||
/** | ||
* Short Description. (use period) | ||
* | ||
* Long Description. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
public static function deactivate() { | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
/** | ||
* Define the internationalization functionality | ||
* | ||
* Loads and defines the internationalization files for this plugin | ||
* so that it is ready for translation. | ||
* | ||
* @link https://enriquechavez.co | ||
* @since 1.0.0 | ||
* | ||
* @package Jwt_Auth | ||
* @subpackage Jwt_Auth/includes | ||
*/ | ||
|
||
/** | ||
* Define the internationalization functionality. | ||
* | ||
* Loads and defines the internationalization files for this plugin | ||
* so that it is ready for translation. | ||
* | ||
* @since 1.0.0 | ||
* @package Jwt_Auth | ||
* @subpackage Jwt_Auth/includes | ||
* @author Enrique Chavez <[email protected]> | ||
*/ | ||
class Jwt_Auth_i18n { | ||
|
||
/** | ||
* The domain specified for this plugin. | ||
* | ||
* @since 1.0.0 | ||
* @access private | ||
* @var string $domain The domain identifier for this plugin. | ||
*/ | ||
private $domain; | ||
|
||
/** | ||
* Load the plugin text domain for translation. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
public function load_plugin_textdomain() { | ||
|
||
load_plugin_textdomain( | ||
$this->domain, | ||
false, | ||
dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/' | ||
); | ||
|
||
} | ||
|
||
/** | ||
* Set the domain equal to that of the specified domain. | ||
* | ||
* @since 1.0.0 | ||
* @param string $domain The domain that represents the locale of this plugin. | ||
*/ | ||
public function set_domain( $domain ) { | ||
$this->domain = $domain; | ||
} | ||
|
||
} |
Oops, something went wrong.