bhujel/secret-header

Package for create api secret key and bind api for authenticated access

1.1.9 2022-04-22 03:54 UTC

This package is auto-updated.

Last update: 2024-04-22 08:11:28 UTC


README

Api Accessor is package to protect your application api for laravel.If you are developing your application it will helpful for you to extend your application.

Compatible for

Laravel Version Version
8.* 1.*

License

The Laravel framework is open-sourced software licensed under the MIT license.

prerequisites

Installation of the package

  • Run the below command to install package
composer require bhujel/secret-header

Package will install inside your laravel application.

- Run the below command to copy config file inside config
  php artisan vendor:publish --tag=api-accessor

You can make changes of your database information and requirement for your application to apply for the package processing

- After successfully publishing vendor api_processor.php will appear in config file inside your root application. - Api Processor assets file is auto generated inside your public directory. - Now you need table to store api keys , run the below command to migrate the table, it will create access_keys and access_key_usages table in your database
  php artisan migrate

-Now run the command to publish assets and check for environment variable for the application .env

  php artisan install:api_accessor

-Now your package is ready you can visit access dashboard using your {your app url}/dashboard/accessor

   {your app url}/dashboard/accessor

Access Key list is below url

   {your app url}/dashboard/access_keys

You can add TEST or LIVE API ACCESS keys and maintain your api if required.

Using in API

You can customize and use keys on your api request

- Add on your api header to access your api. Once the package is installed you can only able to access your api after adding and managing at least on api key.
  1. Add one api key with active status.
  2. From api_processor.php file inside your config dir of application has predefined keys for package. Default api access key header is
API-ACCESS-KEY 

but recomanded to setup your custom key name.

Copy and add paste your api key to your key name header.

3. default it will resposes html on failed to access api you can manage response from handler.php file. 4. If the api key is valid and accessible then you are now able to play on your apis.