Skip to content

Commit

Permalink
Stable release 1.2.0 and updating docs
Browse files Browse the repository at this point in the history
  • Loading branch information
srtfisher committed Feb 23, 2024
1 parent 9c2b6ee commit e811b6e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# REST API Guard

Stable tag: 1.1.2
Stable tag: 1.2.0

Requires at least: 6.0

Expand Down Expand Up @@ -121,8 +121,8 @@ add_filter(
### Require JSON Web Token (JWT) Authentication for Anonymous Users

Anonymous users can be required to authenticate via a JSON Web Token (JWT) to
access the REST API. This can be configured in the plugin's settings or via
code:
access the REST API. Users should pass an `Authorization: Bearer <token>` header
with their request. This can be configured in the plugin's settings or via code:

```php
add_filter( 'rest_api_guard_authentication_jwt', fn () => true );
Expand All @@ -149,7 +149,9 @@ add_filter( 'rest_api_guard_jwt_secret', fn ( string $secret ) => 'my-custom-sec
### Allow JWT Authentication for Authenticated Users

Authenticated users can be authenticated with the REST API via a JSON Web Token.
This can be configured in the plugin's settings or via code:
Similar to the anonymous JWT authentication, users should pass an
`Authorization: Bearer <token>` header with their request. This can be
configured in the plugin's settings or via code:

```php
add_filter( 'rest_api_guard_user_authentication_jwt', fn () => true );
Expand All @@ -158,10 +160,10 @@ add_filter( 'rest_api_guard_user_authentication_jwt', fn () => true );
### Generating JWTs for Anonymous and Authenticated Users

JWTs can be generated by calling the `wp rest-api-guard generate-jwt [--user=<user_id>]`
command or with the `generate_jwt()` method:
command or using the `Alley\WP\REST_API_Guard\generate_jwt()` method:

```php
$jwt = generate_jwt(
$jwt = \Alley\WP\REST_API_Guard\generate_jwt(
expiration: 3600, // Optional. The expiration time in seconds from now.
user: 1, // Optional. The user ID to generate the JWT for. Supports `WP_User` or user ID.
);
Expand Down
17 changes: 10 additions & 7 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
=== REST API Guard ===
Stable tag: 1.1.2
Stable tag: 1.2.0
Requires at least: 6.0
Tested up to: 6.3
Requires PHP: 8.0
Expand Down Expand Up @@ -92,8 +92,8 @@ via code:
### Require JSON Web Token (JWT) Authentication

Anonymous users can be required to authenticate via a JSON Web Token (JWT) to
access the REST API. This can be configured in the plugin's settings or via
code:
access the REST API. Users should pass an `Authorization: Bearer <token>` header
with their request. This can be configured in the plugin's settings or via code:

add_filter( 'rest_api_guard_authentication_jwt', fn () => true );

Expand Down Expand Up @@ -129,16 +129,19 @@ The JWT's secret will be autogenerated and stored in the database in the
### Allow JWT Authentication for Authenticated Users

Authenticated users can be authenticated with the REST API via a JSON Web Token.
This can be configured in the plugin's settings or via code:
Similar to the anonymous JWT authentication, users should pass an
`Authorization: Bearer <token>` header with their request. This can be
configured in the plugin's settings or via code:

add_filter( 'rest_api_guard_user_authentication_jwt', fn () => true );

### Generating JWTs for Anonymous and Authenticated Users

JWTs can be generated by calling the `wp rest-api-guard generate-jwt [--user=<user_id>]`
command or with the `generate_jwt()` method:
JWTs can be generated by calling the
`wp rest-api-guard generate-jwt [--user=<user_id>]` command or using the
`Alley\WP\REST_API_Guard\generate_jwt()` method:

$jwt = generate_jwt(
$jwt = \Alley\WP\REST_API_Guard\generate_jwt(
expiration: 3600, // Optional. The expiration time in seconds from now.
user: 1, // Optional. The user ID to generate the JWT for. Supports `WP_User` or user ID.
);

0 comments on commit e811b6e

Please sign in to comment.