Download the PHP package kasitaw/api-key without Composer
On this page you can find all versions of the php package kasitaw/api-key. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kasitaw/api-key
More information about kasitaw/api-key
Files in kasitaw/api-key
Package api-key
Short Description User defined api key(using custom laravel guard) to enable client communicate with server for external integration in general
License MIT
Informations about the package api-key
API Key Guard for Laravel
This package makes it easy to authenticate users using user defined api key
authentication guard with Laravel 6.0+
Installation
API Key can be installed via composer:
The package will automatically register itself.
You can publish the migration with:
After the migration has been published, run the migrations with following command:
You can publish the config file with:
This is the contents of the published config file:
Usages
Before started, configure config/auth.php
guard as following:
Use HasApiKey.php
trait inside App\User.php
model or any model that implement \Illuminate\Contracts\Auth\Authenticatable
interface:
Call endpoint with middleware as following:
Finally, lets authenticate. 3 ways to pass in the generated key
- Using query params.
i.e /users?api_key=xxx
- Using http body.
i.e api_key = xxx
- Using
Authorization
header.i.e Authorization Bearer xxx
Notes: The request header should be provide
Accept
header. i.eAccept: application/json
Available Methods to manage the key
Generate new api key that ties up to the authenticate user
Activate all existing keys
Activate the key using key
Activate the key using uuid
Revoke all existing keys
Revoke the key using key
Revoked the key using uuid
Delete the key using key
Delete the key using uuid
Get all keys
Delete all keys
Get all active keys
Get all in-active keys
Check whether key is active
Or directly check the key is active
Test
Run test with following command
License
This package is open-sourced software licensed under the MIT license