Skip to content

Commit

Permalink
Fixing README
Browse files Browse the repository at this point in the history
  • Loading branch information
srtfisher committed Jan 15, 2024
1 parent 7d6ccff commit ec9099a
Showing 1 changed file with 20 additions and 26 deletions.
46 changes: 20 additions & 26 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,40 +91,34 @@ 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:

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

Out of the box, the plugin will look for a JWT in the `Authorization: Bearer
<token>` header. The JWT will be expected to have an audience of 'wordpress-rest-api' and issuer of the site's URL. This can be configured in the plugin's settings or via code:

```php
add_filter(
'rest_api_guard_jwt_audience',
function ( string $audience ): string {
return 'custom-audience';
}
);

add_filter(
'rest_api_guard_jwt_issuer',
function ( string $issuer ): string {
return 'https://example.com';
}
);
```
add_filter(
'rest_api_guard_jwt_audience',
function ( string $audience ): string {
return 'custom-audience';
}
);

add_filter(
'rest_api_guard_jwt_issuer',
function ( string $issuer ): string {
return 'https://example.com';
}
);

The JWT's secret will be autogenerated and stored in the database in the
`rest_api_guard_jwt_secret` option. The secret can also be changed via code:

```php
add_filter(
'rest_api_guard_jwt_secret',
function ( string $secret ): string {
return 'my-custom-secret';
}
);
```
add_filter(
'rest_api_guard_jwt_secret',
function ( string $secret ): string {
return 'my-custom-secret';
}
);

You can generate a JWT for use with the REST API by calling the
`wp rest-api-guard generate-jwt` command.

0 comments on commit ec9099a

Please sign in to comment.