azzarip/api-basic-auth

Basic auth system for intraserver api communication

1.1.1 2025-08-05 22:38 UTC

This package is auto-updated.

Last update: 2025-08-11 20:31:43 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package enables secure API communication between two Laravel applications using HTTP Basic Authentication.

Install the package on both applications that need to communicate.

In your .env or config/services.php, define the following:

  • Inbound Password
    Used to authenticate incoming API requests from the other server.

  • Outbound Password
    Used when this application sends outgoing API requests to the other server.

  • Endpoint
    The full URL of the other server (e.g., https://api.example.com).

Installation

You can install the package via composer:

composer require azzarip/api-basic-auth

In the config/services.php add the following

'username' => [
    'endpoint' => 'http....' //full url for calls
    'inbound_password' => env('INBOUND_PASSWORD'),
    'outbound_password' => env('OUTBOUND_PASSWORD'),
]

You can define multiple username each of them with endpoint and inbound and outbound password.

Usage

Inbound Requests

For the inbound request use the api.auth middleware, followed by the username as specified in the config file.

Route::get('/api')->middleware('api.auth:username');

This middleware will let all the request with username username and password inbound_password, as specified in the config files.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.