Simple Laravel JWT AUTH. build with Laravel 8, PHP 8, and MariaDB.
Route prefix is auth
, for detail check at routes/api.php
Method | Endpoint |
---|---|
POST | /api/auth/register |
POST | /api/auth/login |
GET | /api/auth/user-profile |
POST | /api/auth/refresh |
POST | /api/auth/logout |
- Clone this project
git clone https://github.com/reptr/laravel-jwt-auth /direktori project(htdoc)
-
Create database
-
Edit .env
DB_DATABASE= (fill database)
DB_USERNAME= (fill username)
DB_PASSWORD= (fill password)
- Composer Install
composer install
- Migrate database
php artisan migrate
- Generate Key
php artisan key:generate
- Generate Secret Key JWT
php artisan jwt:secret
After generated, you can check this key inside the .env
file
- Finally, Running app
php artisan serve
- User Registration
- Login
-
User Profile
Make sure
fill token
the header fieldAuthorization: Bearer Token
-
JWT Token Refresh
Make sure
fill token
the header fieldAuthorization: Bearer Token
-
Logout
Make sure
fill token
the header fieldAuthorization: Bearer Token
MIT License © 2021