Small Application Role Management using lumen 5.4
Lumen is a micro-framework built on top of Laravel. The framework is used to build faster REST APIs.I have used Lumen 5.4 for this project.
Ref: https://lumen.laravel.com/
JWT token grand access to resources on authentication. The package tymon/jwt is used with lumen for generating token.
Ref: https://jwt.io/
https://iwader.co.uk/post/tymon-jwt-auth-with-lumen-5-2
1 Open MySQL in your machine.
2 Create a blank Database and name it as integrated_system.
3 Import integrated_system.sql file to integrated_system database.
4 Go to project folder and open .env file.
5 Set your MySQL access credentials.
DB_USERNAME=your db username.
DB_PASSWORD= your db password
6 Go to project folder via command line
7 Type following command and hit enter.
php -S localhost:8000 -t public
Example c:\Integrated-system-user>php -S localhost:8000 -t public
Server would be running at localhost:8000
The main endpoint of this project is http http://localhost:8000/
Where basically you will have the URLs open (you don't need the header token):
To get Jwt authentication token you have to login to the system using credentials of superadmin.Data is to be sent in json format. Once you have logged in you have to send token in each request header.
{
"user_name": "superadmin",
"password": "123"
}
{
"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sb2NhbGhvc3Q6ODAwMFwvYXV0aFwvbG9naW4iLCJpYXQiOjE1NzA2OTQxMjQsImV4cCI6MTU3MDY5NzcyNCwibmJmIjoxNTcwNjk0MTI0LCJqdGkiOiJWZFVaWTAwcmJxSFE1Y3NIIiwic3ViIjoxLCJwcnYiOiI4N2UwYWYxZWY5ZmQxNTgxMmZkZWM5NzE1M2ExNGUwYjA0NzU0NmFhIn0.WLRxruEpI5uBNA8GrrfZsJRYm3Q9HUBgXyzTH1RXk3A"
}
For creating a new user you can make use of this API.
{
"user_name": "fayas",
"password": "1234",
" role_id ": "4",
}
{
"message": "User created"
}
example:http://localhost:8000/api/v1/update/user/2
For updating a existing user you can make use of this API.You can’t change the role of super user.
{
"role_id ": "2",
}
{ "message": "User Updated" }
if the composer install not working properly please unzip vendor.zip folder and replace existing vendor folder