Download the PHP package tlx3/laravel-jwt-starter without Composer
On this page you can find all versions of the php package tlx3/laravel-jwt-starter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tlx3/laravel-jwt-starter
More information about tlx3/laravel-jwt-starter
Files in tlx3/laravel-jwt-starter
Package laravel-jwt-starter
Short Description Boilerplate for using your own API based JWT authentication on Laravel applications
License MIT
Homepage https://github.com/TLX3/laravel-jwt-starter
Informations about the package laravel-jwt-starter
laravel-jwt-starter
In a microservice oriented architecture, a client component will communicate with set of microservices where interactions need to be authenticated and authorized. Usually, the users of these microservices will authenticate using the same API in this system. Often, the creation of a login page and authentication middleware will need to be replicated in each of these microservices.
Given a Laravel application, this package will create a generic login with relevant jwt middleware to authenticate the user into your authentication API. This Laravel boilerplate can be added to an existing or new project with minimal configuration. It publishes the respective views, css, and middleware into your project. These can be configured to your needs.
Installation
To install this package you will need:
- Laravel 5
- PHP 5.4 +
Run
Register this package's Service Provider by adding it to the providers
section of your config/app.php
file:
Then to publish the necessary middleware, views, and css:
Also, you will need to install these packages
- Forms & HTML - laravelcollective/html
- Update service providers and aliases in
config/app.php
file
- PHP-JWT - firebase/php-jwt
- Guzzle - guzzlehttp/guzzle
This project integrates these three packages for a form builder, token decoder, and HTTP Client. These packages have numerous features that will help with development over time by reducing overhead.
1) Environment variables
Set your authentication API endpoint, JWT secret, and successful login response code
in your .env
file, you can add/remove to fit your requirements in auth:
2) Middleware
Update $routeMiddleware in app/Http/Middleware/kernel.php
file with the additional middleware added. You should modify these along with the login.blade.php view to fit your application logic:
3) Routes
Update routes/web.php
with these routes. You can modify and change these routes to fit your project, I've added a filler home page as a landing page after logging in:
4) Usage
After installation you can now go to /login
and attempt to login and access protected routes as set prior.
Alongside the routes, you will probably want to modify both views/login.blade.php
and app/Http/Middleware/Login.php
to fit your application logic. The authentication inputs are set here along with the .env variables names that you can customize. You should also modify Login and CheckToken middleware to decode the token for neccessary payload items if needed.
License
MIT