@@ -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:
109102You can use ` \Firebase\JWT\JWT::encode() ` of the [ firebase/php-jwt] ( https://github.com/firebase/php-jwt )
110103lib, 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
113106Users model and find record matching the "id" field.**
114107
108+ Ideally you should also specify the token expiry time using ` exp ` claim.
109+
115110You can set the ` queryDatasource ` option to ` false ` to directly return the token's
116111payload as user info without querying datasource for matching user record.
117112
0 commit comments