Httpauth
Httpauth stats
- Downloads
- 5.5M
- Stars
- 72
- Open Issues
- 1
- Forks
- 12
HTTP Authentication Management for PHP
Intervention HttpAuth
Intervention HttpAuth is a Laravel package that facilitates the management of HTTP authentication in PHP applications. It supports basic and digest authentication methods, providing a straightforward mechanism for securing web resources.
Key Features:
- Multiple Authentication Methods: Supports basic and digest authentication.
- Flexible Instance Creation: Offers several ways to create authentication instances, including static factory methods and class constructors.
- Easy Integration: Simple to integrate with any PHP application using Composer.
Installation:
Install the package using Composer with the following command:
$ composer require intervention/httpauth
Usage:
Creating an Authentication Instance:
You can create an authentication instance using one of the following methods:
-
Static Factory Method:
use Intervention\HttpAuth\Authenticator;$auth = Authenticator::basic('Secured Realm');$auth->withUsername('admin');$auth->withPassword('secret'); -
Static Universal Factory Method:
$auth = Authenticator::make(['type' => 'basic','realm' => 'Secure Resource','username' => 'admin','password' => 'secret',]); -
Class Constructor:
$auth = new Authenticator('basic','Secure Resource','admin','secret');
Securing a Resource:
After creating an instance, secure your resource by invoking the secure() method, which triggers a 401 HTTP response and prompts the user for credentials.
$auth->secure();
Server Configuration:
For Apache users running PHP with FastCGI, specific configuration adjustments may be necessary to ensure proper handling of authorization headers. More details can be found in the provided support link in the package documentation.
Intervention HttpAuth offers a robust and flexible solution for managing HTTP authentication, ensuring your web resources are securely accessed with minimal setup.