PHPackages                             mle86/request-authentication - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. mle86/request-authentication

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

mle86/request-authentication
============================

A simple library for API request authentication.

v0.10.3(7y ago)061[1 issues](https://github.com/mle86/php-request-authentication/issues)MITPHPPHP &gt;=7.1

Since Apr 21Pushed 7y ago1 watchersCompare

[ Source](https://github.com/mle86/php-request-authentication)[ Packagist](https://packagist.org/packages/mle86/request-authentication)[ RSS](/packages/mle86-request-authentication/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (10)Versions (22)Used By (0)

php-request-authentication
==========================

[](#php-request-authentication)

[![Build Status](https://camo.githubusercontent.com/85d7435fee15eef06ab134575780c74a7e6efa9cca46d4bc6d5f819f2bfa557b/68747470733a2f2f7472617669732d63692e6f72672f6d6c6538362f7068702d726571756573742d61757468656e7469636174696f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mle86/php-request-authentication)[![Coverage Status](https://camo.githubusercontent.com/6c1823fa8709ffe1989851d381438ebdf05f5485f3c9eadfe885b2daf2535443/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6d6c6538362f7068702d726571756573742d61757468656e7469636174696f6e2f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/mle86/php-request-authentication?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/ee519556a6b3b77961254071f30fc82b29fa599d1587a0f93936e6857fa5a8ee/68747470733a2f2f706f7365722e707567782e6f72672f6d6c6538362f726571756573742d61757468656e7469636174696f6e2f76657273696f6e)](https://packagist.org/packages/mle86/request-authentication)[![PHP 7.1](https://camo.githubusercontent.com/de440412776a5febe1b7a780ead21feae6f5ab13a1ba20e08406297c27484370/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d372e312d3838393242462e7376673f7374796c653d666c6174)](https://php.net/)[![License](https://camo.githubusercontent.com/fc0bf09eaeb5c8b4682e50decc6443ed0be1810971d291a35c2247e701c1bd9a/68747470733a2f2f706f7365722e707567782e6f72672f6d6c6538362f726571756573742d61757468656e7469636174696f6e2f6c6963656e7365)](https://packagist.org/packages/mle86/request-authentication)

This PHP library provides a generic interface for authenticating outbound API requests and for verifying inbound API requests' authentication.

It is released under the [MIT License](https://opensource.org/licenses/MIT).

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

[](#installation)

Via Composer: `$ composer require mle86/request-authentication`

Or insert this into your project's `composer.json` file:

```
"require": {
    "mle86/request-authentication": "^0"
}
```

Dependencies and Minimum PHP Version
------------------------------------

[](#dependencies-and-minimum-php-version)

- PHP 7.1
- The [PSR-7](https://www.php-fig.org/psr/psr-7/) interfaces ([psr/http-message](https://github.com/php-fig/http-message))
- The [PSR-15](https://www.php-fig.org/psr/psr-15/) interfaces ([psr/http-server-middleware](https://github.com/php-fig/http-server-handler))
- The [whitehat101/apr1-md5](https://packagist.org/packages/whitehat101/apr1-md5) package for `$apr1$` hash support in [BasicHashAuthenticationMethod](doc/Class_BasicHashAuthenticationMethod.md)
- The [paragonie/halite](https://packagist.org/packages/paragonie/halite) package for the [PublicKeyMethod](doc/Class_PublicKeyMethod.md) class

Workflow
--------

[](#workflow)

This library contains several [AuthenticationMethod](doc/Class_AuthenticationMethod.md) classes.

Each of those represents one mechanism for request authentication and verification. The [BasicAuthenticationMethod](doc/Class_BasicAuthenticationMethod.md) for example adds an `Authorization: Basic …` HTTP header to outbound requests and verifies that header in inbound requests against a list of known usernames and their passwords.

Usually the [AuthenticationMethod](doc/Class_AuthenticationMethod.md) classes won't be used directly (apart from instantiating them), there's the [RequestAuthenticator](doc/Class_RequestAuthenticator.md) and [RequestVerifier](doc/Class_RequestVerifier.md) wrapper classes instead that take an AuthenticationMethod dependency.

**To sign/authenticate an outbound request**you'll need an [AuthenticationMethod](doc/Class_AuthenticationMethod.md) instance wrapped in a [RequestAuthenticator](doc/Class_RequestAuthenticator.md) instance, a client ID and a client secret, and the request to sign. The `authenticate()` method will add the required authentication headers to the request so that it can be sent.

**To verify an inbound request**you'll need an [AuthenticationMethod](doc/Class_AuthenticationMethod.md) instance of the same class wrapped in a [RequestVerifier](doc/Class_RequestVerifier.md) instance and a [KeyRepository](doc/Class_KeyRepository.md) that will map the request's client ID to the same client secret used for signing the request.
(In case of the [PublicKeyMethod](doc/Class_PublicKeyMethod.md) class, the client will use its private key for signing and the [KeyRepository](doc/Class_KeyRepository.md) must return the client's public key.)

Classes and Interfaces
----------------------

[](#classes-and-interfaces)

- **Main wrapper classes:**
    - [RequestAuthenticator](doc/Class_RequestAuthenticator.md) wrapper class,
    - [RequestVerifier](doc/Class_RequestVerifier.md) wrapper class.
- **[AuthenticationMethod](doc/Class_AuthenticationMethod.md) main interface:**
    - [BasicAuthenticationMethod](doc/Class_BasicAuthenticationMethod.md) class,
    - [BasicHashAuthenticationMethod](doc/Class_BasicHashAuthenticationMethod.md) class,
    - [DefaultAuthenticationMethod](doc/Class_DefaultAuthenticationMethod.md) class,
    - [PublicKeyMethod](doc/Class_PublicKeyMethod.md) class,
    - [MethodStack](doc/Class_MethodStack.md) composite class.
- [RequestInfo](doc/Class_RequestInfo.md) data transfer object.
- [KeyRepository](doc/Class_KeyRepository.md) base class:
    - [FileRepository](doc/Class_FileRepository.md) class,
    - [ArrayRepository](doc/Class_ArrayRepository.md) class.
- [RequestIdList](doc/Class_RequestIdList.md) interface:
    - [CacheRequestIdList](doc/Class_CacheRequestIdList.md) class.
- [Exception](doc/Exceptions.md) classes.

More Documentation
------------------

[](#more-documentation)

- [Usage Example with htpasswd file](doc/Example_htpasswd.md)
- [Request IDs and Ensuring Request Uniqueness](doc/Request_IDs.md)

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~11 days

Recently: every ~0 days

Total

20

Last Release

2741d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/13321706?v=4)[mle86](/maintainers/mle86)[@mle86](https://github.com/mle86)

---

Top Contributors

[![mle86](https://avatars.githubusercontent.com/u/13321706?v=4)](https://github.com/mle86 "mle86 (145 commits)")

---

Tags

api-authenticationapi-wrapperauthenticationauthentication-middlewarehttp-requestsphp-libraryphp7php71signature-verification

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mle86-request-authentication/health.svg)

```
[![Health](https://phpackages.com/badges/mle86-request-authentication/health.svg)](https://phpackages.com/packages/mle86-request-authentication)
```

###  Alternatives

[league/oauth2-server

A lightweight and powerful OAuth 2.0 authorization and resource server library with support for all the core specification grants. This library will allow you to secure your API with OAuth and allow your applications users to approve apps that want to access their data from your API.

6.6k136.0M248](/packages/league-oauth2-server)[simplesamlphp/saml2

SAML2 PHP library from SimpleSAMLphp

30317.2M40](/packages/simplesamlphp-saml2)[facile-it/php-openid-client

OpenID (OIDC) Client

42592.7k7](/packages/facile-it-php-openid-client)[ecphp/cas-bundle

A bundle for Symfony, providing authentication against a Central Authentication Service (CAS) server.

48132.1k1](/packages/ecphp-cas-bundle)

PHPackages © 2026

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