Httpauth

intervention/httpauth image

Httpauth stats

Downloads
5.5M
Stars
72
Open Issues
1
Forks
12

View on GitHub →

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:

  1. Static Factory Method:

    use Intervention\HttpAuth\Authenticator;
    $auth = Authenticator::basic('Secured Realm');
    $auth->withUsername('admin');
    $auth->withPassword('secret');
  2. Static Universal Factory Method:

    $auth = Authenticator::make([
    'type' => 'basic',
    'realm' => 'Secure Resource',
    'username' => 'admin',
    'password' => 'secret',
    ]);
  3. 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.

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.


Intervention Httpauth Related Articles

A Practical Guide to Laravel's First-Party Image Processing image

A Practical Guide to Laravel's First-Party Image Processing

Read article
RouteKey Model Attribute in Laravel 13.21 image

RouteKey Model Attribute in Laravel 13.21

Read article
First-Party Image Processing in Laravel 13.20 image

First-Party Image Processing in Laravel 13.20

Read article
Stop Failing APIs from Killing Your Queue — Fuse for Laravel image

Stop Failing APIs from Killing Your Queue — Fuse for Laravel

Read article
Cache Smart Invalidation - Laravel In Practice EP10 image

Cache Smart Invalidation - Laravel In Practice EP10

Read article
Enhancing Laravel Queries with Reusable Scope Patterns image

Enhancing Laravel Queries with Reusable Scope Patterns

Read article
PhpStorm logo

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm
No Compromises logo

No Compromises

Joel and Aaron, the two seasoned devs from the No Compromises podcast, are now available to hire for your Laravel project. ⬧ Flat rate of $9500/mo. ⬧ No lengthy sales process. ⬧ No contracts. ⬧ 100% money back guarantee.

No Compromises
Tighten logo

Tighten

We help companies turn great ideas into amazing apps, products, and services.

Tighten
Laravel Cloud logo

Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Laravel Cloud
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell
Acquaint Softtech logo

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech