PHPackages                             intervention/httpauth - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. intervention/httpauth

ActiveLibrary[HTTP &amp; Networking](/categories/http)

intervention/httpauth
=====================

HTTP Authentication Management for PHP

5.0.1(1y ago)8712.3M—3%134MITPHPPHP ^8.2CI passing

Since Feb 9Pushed 2mo ago3 watchersCompare

[ Source](https://github.com/Intervention/httpauth)[ Packagist](https://packagist.org/packages/intervention/httpauth)[ Docs](https://httpauth.intervention.io)[ Fund](https://paypal.me/interventionio)[ GitHub Sponsors](https://github.com/Intervention)[ RSS](/packages/intervention-httpauth/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelogDependencies (4)Versions (27)Used By (4)

Intervention HttpAuth
=====================

[](#intervention-httpauth)

HTTP Authentication Management

[![Latest Version](https://camo.githubusercontent.com/847d4ca72ace3f3e43ce6d8f5ac041c9b8253eb5bfe1beeb80e010e5c904a233/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f696e74657276656e74696f6e2f68747470617574682e737667)](https://packagist.org/packages/intervention/httpauth)[![Tests](https://github.com/Intervention/httpauth/actions/workflows/build.yml/badge.svg)](https://github.com/Intervention/httpauth/actions/workflows/build.yml)[![Monthly Downloads](https://camo.githubusercontent.com/5b15ceba84619bb3b2a43f8d3c553d7591c6e4f06bf95238538022e0be51c5e4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f696e74657276656e74696f6e2f68747470617574682e737667)](https://packagist.org/packages/intervention/httpauth/stats)[![Support me on Ko-fi](https://raw.githubusercontent.com/Intervention/httpauth/main/.github/images/support.svg)](https://ko-fi.com/interventionphp)

Installation
------------

[](#installation)

You can easily install this library using [Composer](https://getcomposer.org). Just request the package with the following command:

```
composer require intervention/httpauth
```

Documentation
-------------

[](#documentation)

Read the full [documentation](https://httpauth.intervention.io) for this library.

Usage
-----

[](#usage)

The workflow is easy. Just create an instance of `Authenticator::class` in the first step and secure your resource in the second step.

### 1. Create Authenticator Instance

[](#1-create-authenticator-instance)

To create authenticator instances you can choose between different methods.

#### Create Instance by Using Static Factory Method

[](#create-instance-by-using-static-factory-method)

```
use Intervention\HttpAuth\Authenticator;

// create http basic auth
$auth = Authenticator::basic(
    'myUsername',
    'myPassword',
    'Secured Area',
);

// create http digest auth
$auth = Authenticator::digest(
    'myUsername',
    'myPassword',
    'Secured Area',
);
```

#### Create Instance by Using Class Constructor

[](#create-instance-by-using-class-constructor)

```
use Intervention\HttpAuth\Authenticator;

// alternatively choose DigestVault::class
$vault = new BasicVault(
    'myUsername',
    'myPassword',
    'Secured Area',
);

$auth = new Authenticator($vault);
```

#### Create Instance by Static Factory Method

[](#create-instance-by-static-factory-method)

```
use Intervention\HttpAuth\Authenticator;

// alternatively choose DigestVault::class
$vault = new BasicVault(
    'myUsername',
    'myPassword',
    'Secured Area',
);

$auth = Authenticator::withVault($vault);
```

### 2. Ask User for Credentials

[](#2-ask-user-for-credentials)

After you created a HTTP authentication instance, you have to call `secure()`to secure the resource. This results in a 401 HTTP response and the browser asking for credentials.

```
$auth->secure();
```

A character string can optionally be passed to the method. This is displayed if authentication fails. Output from template engines can also be used here.

```
$auth->secure('Sorry, you can not access this resource!');
```

Server Configuration
--------------------

[](#server-configuration)

### Apache

[](#apache)

If you are using Apache and running PHP with CGI/FastCGI, check the server configuration to make sure the authorization headers are passed correctly to PHP:

Authors
-------

[](#authors)

This library is developed and maintained by [Oliver Vogel](https://intervention.io)

Thanks to the community of [contributors](https://github.com/Intervention/httpauth/graphs/contributors) who have helped to improve this project.

License
-------

[](#license)

Intervention HttpAuth is licensed under the [MIT License](LICENSE).

###  Health Score

64

—

FairBetter than 99% of packages

Maintenance66

Regular maintenance activity

Popularity61

Solid adoption and visibility

Community23

Small or concentrated contributor base

Maturity86

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 94.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~181 days

Recently: every ~240 days

Total

25

Last Release

498d ago

Major Versions

1.0.3 → 2.0.02015-01-31

2.1.0 → 3.0.0-beta12020-02-21

3.0.3 → 4.0.0-beta12022-05-17

4.0.1 → 5.0.02024-05-03

PHP version history (5 changes)1.0.0PHP &gt;=5.3.0

3.0.0-beta1PHP ^7.2

3.0.2PHP ^7.3|^8.0

4.0.0-beta1PHP ^8.0

5.0.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/7d172b42b2c5b53e71e56589fed3fb3467234a1c266d31b697b1d7b451f4cfe8?d=identicon)[olivervogel](/maintainers/olivervogel)

---

Top Contributors

[![olivervogel](https://avatars.githubusercontent.com/u/884642?v=4)](https://github.com/olivervogel "olivervogel (161 commits)")[![szepeviktor](https://avatars.githubusercontent.com/u/952007?v=4)](https://github.com/szepeviktor "szepeviktor (6 commits)")[![bender270](https://avatars.githubusercontent.com/u/7341240?v=4)](https://github.com/bender270 "bender270 (1 commits)")[![ingria](https://avatars.githubusercontent.com/u/2178368?v=4)](https://github.com/ingria "ingria (1 commits)")[![saschanos](https://avatars.githubusercontent.com/u/4348851?v=4)](https://github.com/saschanos "saschanos (1 commits)")

---

Tags

httpAuthentication

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/intervention-httpauth/health.svg)

```
[![Health](https://phpackages.com/badges/intervention-httpauth/health.svg)](https://phpackages.com/packages/intervention-httpauth)
```

###  Alternatives

[guzzlehttp/psr7

PSR-7 message implementation that also provides common utility methods

7.9k1.0B3.2k](/packages/guzzlehttp-psr7)[psr/http-message

Common interface for HTTP messages

7.1k1.0B5.5k](/packages/psr-http-message)[psr/http-factory

PSR-17: Common interfaces for PSR-7 HTTP message factories

1.9k692.9M1.9k](/packages/psr-http-factory)[league/uri

URI manipulation library

1.1k206.4M277](/packages/league-uri)[league/uri-interfaces

Common tools for parsing and resolving RFC3987/RFC3986 URI

536204.9M23](/packages/league-uri-interfaces)[http-interop/http-factory-guzzle

An HTTP Factory using Guzzle PSR7

581167.2M519](/packages/http-interop-http-factory-guzzle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
