This guide will walk you through the steps needed to get this project up and running on your local machine.
Before you begin, ensure you have the following installed:
- Docker
- Docker Compose
Build and start the containers:
docker-compose up -d --build
docker-compose exec app sh
composer install
Set up the database:
bin/cake migrations migrate
The application should now be accessible at http://localhost:34251
I created 2 accounts with the following information (Please run the migration again if you have run it before):
User1
email: pham.bqt@gmail.com
pass: P@ss1234tai
User2
email: pham.bqt2@gmail.com
pass: P@ss1234tai2
- About the Authentication feature, I use the cakephp/authentication plugin.
- About the Authorization feature, I use the cakephp/authorization plugin.
Ex: How to get access token from this system.
- Request:
POST http://localhost:34251/login
{
"email": "pham.bqt@gmail.com",
"password": "P@ss1234tai"
}
- Response:
- In case of successful login.
HTTP Status Code: 200
{
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJteWFwcCIsInN1YiI6MSwiZXhwIjoxNzEwOTI2NjQ3fQ.Hw12qMLfvEf51wVgEVT1OupSgRRgLyrAUxJugcY36_yMST6NpoNfZ7N0-b7DYYPbaCWQ5evqJf0_ZB6abREgJ0dFYfGano3e7kikIOUB_90sIeo7LBlBJCXvVGLZdtDFw_Qxs_Qqd0rtXiDM3NQ04uFiovVkKZz0DxYVe6y2fA8"
}
- In case of unsuccessful login.
HTTP Status Code: 401
{
"message": "The Username or Password is Incorrect"
}
The received access token will be used to authenticate requests that require authentication. Access token is generated by JWT(JSON Web Tokens). You can get more details at https://jwt.io/.