Skip to content

Commit 3fb1395

Browse files
committed
docs: update readme files with PRO version information
1 parent a6a0045 commit 3fb1395

File tree

2 files changed

+311
-179
lines changed

2 files changed

+311
-179
lines changed

README.md

Lines changed: 146 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,56 @@ A simple plugin to add [JSON Web Token (JWT)](https://tools.ietf.org/html/rfc751
44

55
To know more about JSON Web Tokens, please visit [http://jwt.io](http://jwt.io).
66

7+
## Description
8+
9+
This plugin seamlessly extends the WP REST API, enabling robust and secure authentication using JSON Web Tokens (JWT). It provides a straightforward way to authenticate users via the REST API, returning a standard JWT upon successful login.
10+
11+
### Key features of this free version include:
12+
13+
* **Standard JWT Authentication:** Implements the industry-standard [RFC 7519](https://tools.ietf.org/html/rfc7519) for secure claims representation.
14+
* **Simple Endpoints:** Offers clear `/token` and `/token/validate` endpoints for generating and validating tokens.
15+
* **Configurable Secret Key:** Define your unique secret key via `wp-config.php` for secure token signing.
16+
* **Optional CORS Support:** Easily enable Cross-Origin Resource Sharing support via a `wp-config.php` constant.
17+
* **Developer Hooks:** Provides filters (`jwt_auth_expire`, `jwt_auth_token_before_sign`, etc.) for customizing token behavior.
18+
19+
For users requiring more advanced capabilities such as multiple signing algorithms (RS256, ES256), token refresh/revocation, UI-based configuration, or priority support, consider checking out **[JWT Authentication PRO](https://jwtauth.pro/?utm_source=github_readme&utm_medium=link&utm_campaign=pro_promotion&utm_content=description_link)**.
20+
21+
**Support and Requests:** Please use [GitHub Issues](https://github.com/Tmeister/wp-api-jwt-auth/issues). For priority support, consider upgrading to [PRO](https://jwtauth.pro/support/?utm_source=github_readme&utm_medium=link&utm_campaign=pro_promotion&utm_content=description_support_link).
22+
23+
## JWT Authentication PRO
24+
25+
Elevate your WordPress security and integration capabilities with **JWT Authentication PRO**. Building upon the solid foundation of the free version, the PRO version offers advanced features, enhanced security options, and a streamlined user experience:
26+
27+
* **Easy Configuration UI:** Manage all settings directly from the WordPress admin area.
28+
* **Token Refresh Endpoint:** Allow users to refresh expired tokens seamlessly without requiring re-login.
29+
* **Token Revocation Endpoint:** Immediately invalidate specific tokens for enhanced security control.
30+
* **Customizable Token Payload:** Add custom claims to your JWT payload to suit your specific application needs.
31+
* **Granular CORS Control:** Define allowed origins and headers with more precision directly in the settings.
32+
* **Rate Limiting:** Protect your endpoints from abuse with configurable rate limits.
33+
* **Audit Logs:** Keep track of token generation, validation, and errors.
34+
* **Priority Support:** Get faster, dedicated support directly from the developer.
35+
36+
**[Upgrade to JWT Authentication PRO Today!](https://jwtauth.pro/?utm_source=github_readme&utm_medium=link&utm_campaign=pro_promotion&utm_content=pro_section_cta)**
37+
38+
### Free vs. PRO Comparison
39+
40+
Here's a quick look at the key differences:
41+
42+
| Feature | Free Version | JWT Auth Pro (starts at $59/yr) |
43+
|---------|-------------|--------------------------|
44+
| Basic JWT Authentication | ✅ Included | ✅ Included |
45+
| Token Generation | ✅ Included | ✅ Included |
46+
| Token Validation | ✅ Included | ✅ Included |
47+
| Token Refresh Mechanism | ❌ Not Included | ✅ Included |
48+
| Token Revocation | ❌ Not Included | ✅ Included |
49+
| Token Management Dashboard | ❌ Not Included | ✅ Included |
50+
| Analytics & Monitoring | ❌ Not Included | ✅ Included |
51+
| Geo-IP Identification | ❌ Not Included | ✅ Included |
52+
| Rate Limiting | ❌ Not Included | ✅ Included |
53+
| Detailed Documentation | Basic | Comprehensive |
54+
| Developer Tools | ❌ Not Included | ✅ Included |
55+
| Premium Support | Community via GitHub | Priority Direct Support |
56+
757
## Requirements
858

959
### WP REST API V2
@@ -20,111 +70,103 @@ So, to use the **wp-api-jwt-auth** you need to install and activate [WP REST API
2070

2171
#### Shared Hosts
2272

23-
Most shared hosts have disabled the **HTTP Authorization Header** by default.
73+
Most shared hosting providers have disabled the **HTTP Authorization Header** by default.
2474

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

27-
```
77+
```apache
2878
RewriteEngine on
2979
RewriteCond %{HTTP:Authorization} ^(.*)
3080
RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
3181
```
3282

3383
#### WPEngine
3484

35-
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):
85+
For WPEngine hosting, you'll need to edit your **.htaccess** file by adding the following:
3686

37-
```
87+
```apache
3888
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
3989
```
4090

91+
See https://github.com/Tmeister/wp-api-jwt-auth/issues/1 for more details.
92+
4193
## Installation & Configuration
4294

4395
[Download the zip file](https://github.com/Tmeister/wp-api-jwt-auth/archive/master.zip) and install it like any other WordPress plugin.
4496

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

47-
### Configurate the Secret Key
99+
### Configure the Secret Key
48100

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

51-
To add the **secret key**, edit your wp-config.php file and add a new constant called **JWT_AUTH_SECRET_KEY**.
52-
103+
To add the **secret key**, edit your wp-config.php file and add a new constant called **JWT_AUTH_SECRET_KEY**:
53104

54105
```php
55106
define('JWT_AUTH_SECRET_KEY', 'your-top-secret-key');
56107
```
57108

58-
You can use a string from here https://api.wordpress.org/secret-key/1.1/salt/
109+
You can generate a secure key from: https://api.wordpress.org/secret-key/1.1/salt/
59110

60-
### Configurate CORs Support
111+
**Looking for easier configuration?** [JWT Authentication PRO](https://jwtauth.pro/?utm_source=github_readme&utm_medium=link&utm_campaign=pro_promotion&utm_content=config_secret_key_link) allows you to manage all settings through a simple admin UI.
61112

62-
The **wp-api-jwt-auth** plugin has the option to activate [CORs](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing) support.
113+
### Configure CORS Support
63114

64-
To enable the CORs Support edit your wp-config.php file and add a new constant called **JWT_AUTH_CORS_ENABLE**
115+
The **wp-api-jwt-auth** plugin has the option to activate [CORS](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing) support.
65116

117+
To enable CORS Support, edit your wp-config.php file and add a new constant called **JWT_AUTH_CORS_ENABLE**:
66118

67119
```php
68120
define('JWT_AUTH_CORS_ENABLE', true);
69121
```
70122

71-
72-
Finally activate the plugin within the plugin dashboard.
123+
Finally, activate the plugin within your wp-admin.
73124

74125
## Namespace and Endpoints
75126

76-
When the plugin is activated, a new namespace is added.
77-
127+
When the plugin is activated, a new namespace is added:
78128

79129
```
80130
/jwt-auth/v1
81131
```
82132

133+
Also, two new endpoints are added to this namespace:
83134

84-
Also, two new endpoints are added to this namespace.
135+
| Endpoint | HTTP Verb |
136+
|----------|-----------|
137+
| */wp-json/jwt-auth/v1/token* | POST |
138+
| */wp-json/jwt-auth/v1/token/validate* | POST |
85139

86-
87-
| Endpoint | HTTP Verb |
88-
| ------------------------------------- | --------- |
89-
| */wp-json/jwt-auth/v1/token* | POST |
90-
| */wp-json/jwt-auth/v1/token/validate* | POST |
140+
**Need more functionality?** [JWT Authentication PRO](https://jwtauth.pro/?utm_source=github_readme&utm_medium=link&utm_campaign=pro_promotion&utm_content=endpoints_pro_note) includes additional endpoints for token refresh and revocation.
91141

92142
## Usage
93143
### /wp-json/jwt-auth/v1/token
94144

95-
This is the entry point for the JWT Authentication.
145+
This is the entry point for JWT Authentication.
96146

97-
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.
147+
It validates the user credentials, *username* and *password*, and returns a token to use in future requests to the API if the authentication is correct, or an error if authentication fails.
98148

99-
#### Sample request using AngularJS
149+
#### Sample Request Using AngularJS
100150

101151
```javascript
152+
(function() {
153+
var app = angular.module('jwtAuth', []);
102154

103-
( function() {
104-
var app = angular.module( 'jwtAuth', [] );
105-
106-
app.controller( 'MainController', function( $scope, $http ) {
107-
155+
app.controller('MainController', function($scope, $http) {
108156
var apiHost = 'http://yourdomain.com/wp-json';
109157

110-
$http.post( apiHost + '/jwt-auth/v1/token', {
111-
username: 'admin',
112-
password: 'password'
113-
} )
114-
115-
.then( function( response ) {
116-
console.log( response.data )
117-
} )
118-
119-
.catch( function( error ) {
120-
console.error( 'Error', error.data[0] );
121-
} );
122-
123-
} );
124-
125-
} )();
126-
127-
158+
$http.post(apiHost + '/jwt-auth/v1/token', {
159+
username: 'admin',
160+
password: 'password'
161+
})
162+
.then(function(response) {
163+
console.log(response.data)
164+
})
165+
.catch(function(error) {
166+
console.error('Error', error.data[0]);
167+
});
168+
});
169+
})();
128170
```
129171

130172
Success response from the server:
@@ -150,47 +192,47 @@ Error response from the server:
150192
}
151193
```
152194

153-
Once you get the token, you must store it somewhere in your application, e.g. in a **cookie** or using **localstorage**.
195+
Once you get the token, you must store it somewhere in your application, e.g. in a **cookie** or using **localStorage**.
154196

155-
From this point, you should pass this token to every API call.
197+
From this point, you should pass this token with every API call.
156198

157-
Sample call using the Authorization header using AngularJS:
199+
#### Sample Call Using The Authorization Header With AngularJS
158200

159201
```javascript
160-
app.config( function( $httpProvider ) {
161-
$httpProvider.interceptors.push( [ '$q', '$location', '$cookies', function( $q, $location, $cookies ) {
202+
app.config(function($httpProvider) {
203+
$httpProvider.interceptors.push(['$q', '$location', '$cookies', function($q, $location, $cookies) {
162204
return {
163-
'request': function( config ) {
205+
'request': function(config) {
164206
config.headers = config.headers || {};
165-
//Assume that you store the token in a cookie.
166-
var globals = $cookies.getObject( 'globals' ) || {};
167-
//If the cookie has the CurrentUser and the token
168-
//add the Authorization header in each request
169-
if ( globals.currentUser && globals.currentUser.token ) {
207+
// Assume that you store the token in a cookie
208+
var globals = $cookies.getObject('globals') || {};
209+
// If the cookie has the CurrentUser and the token
210+
// add the Authorization header in each request
211+
if (globals.currentUser && globals.currentUser.token) {
170212
config.headers.Authorization = 'Bearer ' + globals.currentUser.token;
171213
}
172214
return config;
173215
}
174216
};
175-
} ] );
176-
} );
217+
}]);
218+
});
177219
```
178220

179-
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.
221+
The **wp-api-jwt-auth** plugin 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 to the data stored in it.
180222

181-
If the token is valid, the API call flow will continue as always.
223+
If the token is valid, the API call flow will continue as normal.
182224

183225
**Sample Headers**
184226

185-
```
227+
```http
186228
POST /resource HTTP/1.1
187229
Host: server.example.com
188230
Authorization: Bearer mF_s9.B5f-4.1JqM
189231
```
190232

191-
### Errors
233+
## Errors
192234

193-
If the token is invalid an error will be returned. Here are some samples of errors:
235+
If the token is invalid, an error will be returned. Here are some sample errors:
194236

195237
**Invalid Credentials**
196238

@@ -234,9 +276,11 @@ If the token is invalid an error will be returned. Here are some samples of erro
234276
]
235277
```
236278

279+
**Need advanced error tracking?** [JWT Authentication PRO](https://jwtauth.pro/?utm_source=github_readme&utm_medium=link&utm_campaign=pro_promotion&utm_content=errors_pro_note) offers enhanced error tracking and monitoring capabilities.
280+
237281
### /wp-json/jwt-auth/v1/token/validate
238282

239-
This is a simple helper endpoint to validate a token; you only will need to make a POST request sending the Authorization header.
283+
This is a simple helper endpoint to validate a token. You only need to make a POST request with the Authorization header.
240284

241285
Valid Token Response:
242286

@@ -251,11 +295,11 @@ Valid Token Response:
251295

252296
## Available Hooks
253297

254-
The **wp-api-jwt-auth** is dev friendly and has five filters available to override the default settings.
298+
The **wp-api-jwt-auth** plugin is developer-friendly and provides five filters to override the default settings.
255299

256-
#### jwt_auth_cors_allow_headers
300+
### jwt_auth_cors_allow_headers
257301

258-
The **jwt_auth_cors_allow_headers** allows you to modify the available headers when the CORs support is enabled.
302+
The **jwt_auth_cors_allow_headers** filter allows you to modify the available headers when CORS support is enabled.
259303

260304
Default Value:
261305

@@ -265,7 +309,7 @@ Default Value:
265309

266310
### jwt_auth_not_before
267311

268-
The **jwt_auth_not_before** allows you to change the [**nbf**](https://tools.ietf.org/html/rfc7519#section-4.1.5) value before the token is created.
312+
The **jwt_auth_not_before** filter allows you to change the [**nbf**](https://tools.ietf.org/html/rfc7519#section-4.1.5) value before the token is created.
269313

270314
Default Value:
271315

@@ -275,7 +319,7 @@ Creation time - time()
275319

276320
### jwt_auth_expire
277321

278-
The **jwt_auth_expire** allows you to change the value [**exp**](https://tools.ietf.org/html/rfc7519#section-4.1.4) before the token is created.
322+
The **jwt_auth_expire** filter allows you to change the [**exp**](https://tools.ietf.org/html/rfc7519#section-4.1.4) value before the token is created.
279323

280324
Default Value:
281325

@@ -285,7 +329,7 @@ time() + (DAY_IN_SECONDS * 7)
285329

286330
### jwt_auth_token_before_sign
287331

288-
The **jwt_auth_token_before_sign** allows you to modify all the token data before to be encoded and signed.
332+
The **jwt_auth_token_before_sign** filter allows you to modify all token data before it is encoded and signed.
289333

290334
Default value:
291335

@@ -304,8 +348,11 @@ $token = array(
304348
);
305349
```
306350

351+
**Want easier customization?** [JWT Authentication PRO](https://jwtauth.pro/?utm_source=github_readme&utm_medium=link&utm_campaign=pro_promotion&utm_content=hook_payload_pro_note) allows you to add custom claims directly through the admin UI.
352+
307353
### jwt_auth_token_before_dispatch
308-
The **jwt_auth_token_before_dispatch** allows you to modify all the response array before to dispatch it to the client.
354+
355+
The **jwt_auth_token_before_dispatch** filter allows you to modify the response array before it is sent to the client.
309356

310357
Default value:
311358

@@ -320,7 +367,8 @@ $data = array(
320367
```
321368

322369
### jwt_auth_algorithm
323-
The **jwt_auth_algorithm** allows you to modify the signing algorithm.
370+
371+
The **jwt_auth_algorithm** filter allows you to modify the signing algorithm.
324372

325373
Default value:
326374

@@ -340,13 +388,35 @@ $token = JWT::decode(
340388
);
341389
```
342390

391+
**Need more advanced algorithms?** [JWT Authentication PRO](https://jwtauth.pro/?utm_source=github_readme&utm_medium=link&utm_campaign=pro_promotion&utm_content=algorithm_hook_link) supports multiple signing algorithms (RS256, ES256) that you can easily configure through the UI.
392+
393+
## Frequently Asked Questions
394+
395+
### Does this plugin support algorithms other than HS256?
396+
The free version only supports HS256. For support for RS256, ES256, and other algorithms, please consider [JWT Authentication PRO](https://jwtauth.pro/?utm_source=github_readme&utm_medium=link&utm_campaign=pro_promotion&utm_content=faq_algorithms_link).
397+
398+
### Can I manage settings without editing wp-config.php?
399+
The free version requires editing `wp-config.php`. [JWT Authentication PRO](https://jwtauth.pro/?utm_source=github_readme&utm_medium=link&utm_campaign=pro_promotion&utm_content=faq_config_link) provides a full settings UI within the WordPress admin.
400+
401+
### Is there a way to refresh or revoke tokens?
402+
Token refresh and revocation features are available in [JWT Authentication PRO](https://jwtauth.pro/?utm_source=github_readme&utm_medium=link&utm_campaign=pro_promotion&utm_content=faq_refresh_revoke_link).
403+
404+
### Where can I get faster support?
405+
Priority support is included with [JWT Authentication PRO](https://jwtauth.pro/support/?utm_source=github_readme&utm_medium=link&utm_campaign=pro_promotion&utm_content=faq_support_link). For free support, please use the [GitHub issues tracker](https://github.com/Tmeister/wp-api-jwt-auth/issues).
406+
407+
### How secure is JWT authentication?
408+
JWT authentication is very secure when implemented correctly. Make sure to use a strong secret key and keep it confidential. [JWT Auth PRO](https://jwtauth.pro/?utm_source=github_readme&utm_medium=link&utm_campaign=pro_promotion&utm_content=faq_security_link) offers additional security features like rate limiting and token revocation.
409+
343410
## Testing
344-
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](https://github.com/Tmeister/jwt-client)
411+
I've created a small app to test the basic functionality of the plugin. You can get the app and read all the details in the [JWT-Client Repo](https://github.com/Tmeister/jwt-client).
345412

346413
## Credits
347414
[WP REST API V2](http://v2.wp-api.org/)
348415

349416
[PHP-JWT from firebase](https://github.com/firebase/php-jwt)
350417

351-
##License
418+
## License
352419
[GPLv2](http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
420+
421+
---
422+
Want to enhance your JWT authentication with advanced features like token refresh, revocation, UI-based configuration, multiple algorithms, and more? Check out [JWT Authentication PRO](https://jwtauth.pro/?utm_source=github_readme&utm_medium=link&utm_campaign=pro_promotion&utm_content=footer_cta)!

0 commit comments

Comments
 (0)