Skip to content

Commit 1d22060

Browse files
committed
Update readme
1 parent c2948f9 commit 1d22060

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

README.md

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,7 @@ composer require admad/cakephp-jwt-auth
1717

1818
## Usage
1919

20-
In your app's `config/bootstrap.php` add:
21-
22-
```php
23-
// In config/bootstrap.php
24-
Plugin::load('ADmad/JwtAuth');
25-
```
26-
27-
or using cake's console:
20+
Load the plugin using Cake's console:
2821

2922
```sh
3023
./bin/cake plugin load ADmad/JwtAuth
@@ -36,7 +29,7 @@ Setup `AuthComponent`:
3629

3730
```php
3831
// In your controller, for e.g. src/Api/AppController.php
39-
public function initialize()
32+
public function initialize(): void
4033
{
4134
parent::initialize();
4235

@@ -97,9 +90,9 @@ The authentication class checks for the token in two locations:
9790
RewriteCond %{HTTP:Authorization} ^(.*)
9891
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
9992
```
100-
93+
10194
or
102-
95+
10396
```
10497
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
10598
```
@@ -109,9 +102,11 @@ The authentication class checks for the token in two locations:
109102
You can use `\Firebase\JWT\JWT::encode()` of the [firebase/php-jwt](https://github.com/firebase/php-jwt)
110103
lib, which this plugin depends on, to generate tokens.
111104

112-
**The payload should have the "sub" (subject) claim whose value is used to query the
105+
**The payload must have the "sub" (subject) claim whose value is used to query the
113106
Users model and find record matching the "id" field.**
114107

108+
Ideally you should also specify the token expiry time using `exp` claim.
109+
115110
You can set the `queryDatasource` option to `false` to directly return the token's
116111
payload as user info without querying datasource for matching user record.
117112

0 commit comments

Comments
 (0)