diff --git a/readme.txt b/readme.txt index 9270c90..0ec4239 100644 --- a/readme.txt +++ b/readme.txt @@ -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 ` 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.