Download the PHP package irazasyed/jwt-auth-guard without Composer
On this page you can find all versions of the php package irazasyed/jwt-auth-guard. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download irazasyed/jwt-auth-guard
More information about irazasyed/jwt-auth-guard
Files in irazasyed/jwt-auth-guard
Package jwt-auth-guard
Short Description JWT Auth Guard for Laravel and Lumen
License MIT
Homepage https://github.com/irazasyed/laravel-jwt-guard
Informations about the package jwt-auth-guard
JWT Auth Guard
JWT Auth Guard is a Laravel & Lumen Package that lets you use
jwt
as your driver for authentication guard in your application.The Guard uses
tymon/jwt-auth
package for authentication and token handling.
Requirements
- Laravel or Lumen Installation.
- tymon/jwt-auth
^1.0@dev
Package Setup and Config'd.
Pre-Installation
First install and setup tymon/jwt-auth package.
Once done, config it and then install this package.
Install
Via Composer
Add the Service Provider
Laravel
Open config/app.php
and, to your providers
array at the bottom, add:
Lumen
Open bootstrap/app.php
and register the service provider:
Usage
Open your config/auth.php
config file and in place of driver under any of your guards, just add the jwt-auth
as your driver and you're all set.
Make sure you also set provider
for the guard to communicate with your database.
Setup Guard Driver
Middleware Usage
Middleware protecting the route:
Middleware protecting the controller:
Note: The above example assumes you've setup a guard with the name api
whose driver is jwt-auth
in your config/auth.php
file as explained in "Setup Guard Driver" section above.
The following usage examples assume you've setup your default auth guard to the one which uses the
jwt-auth
driver.You can also explicitly define the guard before making calls to any of methods by just prefixing it with
Auth::guard('api')
.Example:
Auth::guard('api')->user()
Attempt To Authenticate And Return Token
Authenticate Once By ID
Authenticate Once By Credentials
Validate Credentials
Check User is Authenticated
Check User is a Guest
Logout Authenticated User
Generate JWT Auth Token By ID
Get Authenticated User
Once the user is authenticated via a middleware, You can access its details by doing:
You can also manually access user info using the token itself:
Get Authenticated User's ID
Refresh Expired Token
Though it's recommended you refresh using the middlewares provided with the package, but if you'd like, You can also do it manually with this method.
Refresh expired token passed in request:
Refresh passed expired token:
Invalidate Token
Invalidate token passed in request:
Invalidate token by setting one manually:
Get Token
Get Token Payload
This method will decode the token and return its raw payload.
Get Payload for the token passed in request:
Get Payload for the given token manually:
Change log
Please see CHANGELOG for more information what has changed recently.
Testing
Contributing
Please see CONDUCT for details.
Any issues, feedback, suggestions or questions please use issue tracker here.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- Syed Irfaq R.
- All Contributors
License
The MIT License (MIT). Please see License File for more information.