Laravel Cloud is here! Zero-config managed infrastructure for Laravel apps. Deploy now.

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

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
Intervention Image image

Intervention Image

Read article
Harpoon: Next generation time tracking and invoicing logo

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing
Shift logo

Shift

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

Shift
Laravel Cloud logo

Laravel Cloud

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

Laravel Cloud
Celebian logo

Celebian

Celebian is a social media marketing agency specializing in helping their clients go viral on TikTok. Whether you're looking to reach a bigger audience or gain more Tiktok followers, likes, and views, they've got you covered.

Celebian
Honeybadger logo

Honeybadger

Simple developer-focused application monitoring for Laravel. Error tracking, log management, uptime monitoring, status pages, and more!

Honeybadger
Tighten logo

Tighten

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

Tighten