Download the PHP package drozzi-pro/wp-api-jwt-auth without Composer

On this page you can find all versions of the php package drozzi-pro/wp-api-jwt-auth. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package wp-api-jwt-auth

JWT Authentication for the WP REST API

A simple plugin to add JSON Web Token (JWT) Authentication to the WP REST API.

To know more about JSON Web Tokens, please visit http://jwt.io.

Requirements

WP REST API V2

This plugin was conceived to extend the WP REST API V2 plugin features and, of course, was built on top of it.

So, to use the wp-api-jwt-auth you need to install and activate WP REST API.

PHP

Minimum PHP version: 7.4.0

Enable PHP HTTP Authorization Header

Shared Hosts

Most shared hosts have disabled the HTTP Authorization Header by default.

To enable this option you'll need to edit your .htaccess file by adding the following:

WPEngine

To enable this option you'll need to edit your .htaccess file by adding the following (see https://github.com/Tmeister/wp-api-jwt-auth/issues/1):

Installation & Configuration

Download the zip file and install it like any other WordPress plugin.

Or clone this repo into your WordPress installation into the wp-content/plugins folder.

Configurate the Secret Key

The JWT needs a secret key to sign the token. This secret key must be unique and never revealed.

To add the secret key, edit your wp-config.php file and add a new constant called JWT_AUTH_SECRET_KEY.

You can use a string from here https://api.wordpress.org/secret-key/1.1/salt/

Configurate CORs Support

The wp-api-jwt-auth plugin has the option to activate CORs support.

To enable the CORs Support edit your wp-config.php file and add a new constant called JWT_AUTH_CORS_ENABLE

Finally activate the plugin within the plugin dashboard.

Namespace and Endpoints

When the plugin is activated, a new namespace is added.

Also, two new endpoints are added to this namespace.

Endpoint HTTP Verb
/wp-json/jwt-auth/v1/token POST
/wp-json/jwt-auth/v1/token/validate POST

Usage

/wp-json/jwt-auth/v1/token

This is the entry point for the JWT Authentication.

Validates the user credentials, username and password, and returns a token to use in a future request to the API if the authentication is correct or error if the authentication fails.

Sample request using AngularJS

Success response from the server:

Error response from the server:

Once you get the token, you must store it somewhere in your application, e.g. in a cookie or using localstorage.

From this point, you should pass this token to every API call.

Sample call using the Authorization header using AngularJS:

The wp-api-jwt-auth will intercept every call to the server and will look for the authorization header, if the authorization header is present, it will try to decode the token and will set the user according with the data stored in it.

If the token is valid, the API call flow will continue as always.

Sample Headers

Errors

If the token is invalid an error will be returned. Here are some samples of errors:

Invalid Credentials

Invalid Signature

Expired Token

/wp-json/jwt-auth/v1/token/validate

This is a simple helper endpoint to validate a token; you only will need to make a POST request sending the Authorization header.

Valid Token Response:

Available Hooks

The wp-api-jwt-auth is dev friendly and has five filters available to override the default settings.

jwt_auth_cors_allow_headers

The jwt_auth_cors_allow_headers allows you to modify the available headers when the CORs support is enabled.

Default Value:

jwt_auth_not_before

The jwt_auth_not_before allows you to change the nbf value before the token is created.

Default Value:

jwt_auth_expire

The jwt_auth_expire allows you to change the value exp before the token is created.

Default Value:

jwt_auth_token_before_sign

The jwt_auth_token_before_sign allows you to modify all the token data before to be encoded and signed.

Default value:

jwt_auth_token_before_dispatch

The jwt_auth_token_before_dispatch allows you to modify all the response array before to dispatch it to the client.

Default value:

jwt_auth_algorithm

The jwt_auth_algorithm allows you to modify the signing algorithm.

Default value:

Testing

I've created a small app to test the basic functionality of the plugin; you can get the app and read all the details on the JWT-Client Repo

Credits

WP REST API V2

PHP-JWT from firebase

License

GPLv2


All versions of wp-api-jwt-auth with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
composer/installers Version ~2.2
firebase/php-jwt Version ^6.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package drozzi-pro/wp-api-jwt-auth contains the following files

Loading the files please wait ....