This project is proof of concept on implementation of JWT authentication in CakePHP using Authentication plugin.
-
Download the repo locally:
git clone git@github.com:ishanvyas22/cakephp-jwt-authentication-demo.git cd cakephp-jwt-authentication-demo
-
Install PHP dependencies:
composer install
-
Read and edit the environment specific
config/app_local.php
and setup the'Datasources'
and any other configuration relevant for your application. Other environment agnostic settings can be changed inconfig/app.php
. -
Run database migrations & seeders:
bin/cake migrations migrate bin/cake migrations seed --seed=DatabaseSeed
-
Run the dev server (the output will give the address):
bin/cake server
That's all!
You can send a POST
request to /api/users/login.json
URL with below details:
- Username: john
- Password: secret
It will return JWT token in json response.
To get authenticated user's information you have to make a GET
request to /api/users.json
URL with the token you got from previous step in the Authorization
header with Bearer
prefix.
Do you like this project? Support it by donating:
or Paypal me
The MIT License (MIT). Please see License File for more information.