Package Data | |
---|---|
Maintainer Username: | erjanmx |
Maintainer Contact: | erjanmx@gmail.com (erjanmx) |
Package Create Date: | 2017-06-27 |
Package Last Update: | 2021-04-08 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-15 15:15:44 |
Package Statistics | |
---|---|
Total Downloads: | 22,455 |
Monthly Downloads: | 60 |
Daily Downloads: | 0 |
Total Stars: | 19 |
Total Watchers: | 2 |
Total Forks: | 2 |
Total Open Issues: | 1 |
Laravel gives easy ways to handle api authorization using user based tokens, but sometimes you need to use a single token to give access to your application, especially when you're developing two apps that need to be connected, or perhaps you're in need of connecting Telegram-bot to your app endpoint using webhooks
Laravel-api-auth makes that easy as breathe, no migrations, no models
If you're using Laravel prior to 5.5, consider using v0.1 branch
$ composer require erjanmx/laravel-api-auth
Publish the Package configuration
$ php artisan vendor:publish --provider="Apiauth\Laravel\CAuthServiceProvider"
Change defaults in config/apiauth.php
setting
.env
file for example REMOTE_APP_TOKEN
.env
file// .env
...your other variables
REMOTE_APP_TOKEN=<secret-token>
// /routes/api.php
Route::group(['prefix' => 'v1', 'middleware' => ['apiauth:REMOTE_APP']], function () {
// your routes
});
Your urls within your group is accessible only if valid token is provided
GET
or POST
requestAuthorization Bearer
json
raw bodyYou're free to change token name (api_token
by default) in configuration file as well as
authorization methods to be checked.
Also you can set as many services as you want.