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

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
Manipulate Image URLs in Laravel with the Image Transform Package image

Manipulate Image URLs in Laravel with the Image Transform Package

Read article
Stargazing in Your Laravel App with Intervention Zodiac image

Stargazing in Your Laravel App with Intervention Zodiac

Read article
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
Tinkerwell logo

Tinkerwell

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

Tinkerwell
Curotec logo

Curotec

World class Laravel experts with GenAI dev skills. LATAM-based, embedded engineers that ship fast, communicate clearly, and elevate your product. No bloat, no BS.

Curotec
Securing Laravel logo

Securing Laravel

The essential security resource for Laravel devs, covering everything you need to keep your apps secure. Sign up to receive weekly security tips and monthly in depth articles, diving deep into security concepts you need to know!

Securing Laravel
Statamic logo

Statamic

The drop-in ready Laravel CMS you’re been waiting for. Go full-stack or headless, flat file or database – it’s up to you.

Statamic
Tighten logo

Tighten

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

Tighten