PHPackages                             devster/uauth - 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. devster/uauth

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

devster/uauth
=============

Micro PHP HTTP authentication library

1.1.0(10y ago)5420MITPHPPHP &gt;=5.3

Since Oct 12Pushed 10y ago1 watchersCompare

[ Source](https://github.com/devster/uauth)[ Packagist](https://packagist.org/packages/devster/uauth)[ Docs](https://github.com/devster/uauth)[ RSS](/packages/devster-uauth/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (2)Versions (3)Used By (0)

Uauth
=====

[](#uauth)

[![Build Status](https://camo.githubusercontent.com/13bc5da8fdd6d9800bbbd1e682af559f6995e33ff1e67d2b871304c619c67f68/68747470733a2f2f7472617669732d63692e6f72672f646576737465722f75617574682e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/devster/uauth)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/d7104e5d454da33c8df4e991ac0eeb80f58e1ce3e1a39163bf5a4e32b4826427/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f646576737465722f75617574682f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/devster/uauth/?branch=master)[![PHP version](https://camo.githubusercontent.com/9a0b6f45f2a2be859aa941c3daac93bc90c6d7504a31a6c95bbef731ca3b70df/68747470733a2f2f62616467652e667572792e696f2f70682f6465767374657225324675617574682e737667)](http://badge.fury.io/ph/devster%2Fuauth)

Micro PHP HTTP authentication library

[![](https://camo.githubusercontent.com/02a8a40d38610719cddefff46654e97b195f7b6190eb5472791d1fd3a4f46cf5/687474703a2f2f692e696d6775722e636f6d2f676178446768456c2e706e67)](https://camo.githubusercontent.com/02a8a40d38610719cddefff46654e97b195f7b6190eb5472791d1fd3a4f46cf5/687474703a2f2f692e696d6775722e636f6d2f676178446768456c2e706e67)

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

[](#installation)

```
composer require devster/uauth "1.*"

```

Or require a single file

```
require_once 'src/Basic.php';

use Uauth\Basic;
```

Usage
-----

[](#usage)

### HTTP Basic

[](#http-basic)

#### Simple usecase

[](#simple-usecase)

```
require_once 'vendor/autoload.php';

// Here is the most simple usecase
$basic = new \Uauth\Basic("Secured Area", ['john' => 'd0e!', 'jon' => '5n0w']);
$basic->auth();
// All code below is secured by HTTP basic, and you can access the user
echo "Welcome ", $basic->getUser();
```

#### More complex usecase

[](#more-complex-usecase)

```
$basic = new \Uauth\Basic("Secured Area");
$basic
    // Implement your own user verification system.
    // The callable must return true if user is allowed, false if not
    ->verify(function ($username, $password) use ($db) {
        $user = $db->findUser($username);
        return $user->password == $password;
    })
    // this code is executed if the login modal is cancelled
    // or if the user is not verified
    ->deny(function () {
        echo "This text appears because you hit the cancel button";
    })
;
$basic->auth();

echo "Welcome ", $basic->getUser(), ", you password is ", $basic->getPassword();
```

#### Silex integration

[](#silex-integration)

```
$app = new Silex\Application();

$app['allowedUsers'] = ['jon' => '5n0w'];

// Create your silex middleware
$httpBasicAuth = function () use ($app) {
    $basic = new \Uauth\Basic("Secured Silex Area", $app['allowedUsers']);
    $basic->auth();

    // we save the current user
    $app['user'] = $basic->getUser();
};

// And now you can use your middleware where you see fit

// Protect the entire app
$app->before($httpBasicAuth);

// Or protect a collection of routes
$blog = $app['controllers_factory'];
$blog->before($httpBasicAuth);
$blog->get('/', function () {
    return 'Blog home page';
});
$app->mount('/private_blog', $blog);

// Or protect a single route
$app->get('/hello', function () use ($app) {
    return 'Hello '.$app->escape($app['user']);
})->before($httpBasicAuth);

$app->run();
```

Tests
-----

[](#tests)

You will need php &gt;= 5.4 if you want to run tests with php built-in web server.

```
php -S localhost:8080 -t tests/server
vendor/bin/phpunit

```

License
-------

[](#license)

This project is licensed under the MIT License

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 87.5% 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 ~489 days

Total

2

Last Release

3747d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8620f3809131894195e57dcaf70f3468f009b39dd4ebf220a964f580c38afc80?d=identicon)[devster](/maintainers/devster)

---

Top Contributors

[![devster](https://avatars.githubusercontent.com/u/1135083?v=4)](https://github.com/devster "devster (7 commits)")[![djmattyg007](https://avatars.githubusercontent.com/u/489338?v=4)](https://github.com/djmattyg007 "djmattyg007 (1 commits)")

---

Tags

httpmicroauthlibrarybasic

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/devster-uauth/health.svg)

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

###  Alternatives

[eljam/guzzle-jwt-middleware

A jwt authentication middleware for guzzle 6

28722.5k3](/packages/eljam-guzzle-jwt-middleware)[sven/super-basic-auth

A lightweight package to add basic authentication to your Laravel app.

232.6k](/packages/sven-super-basic-auth)

PHPackages © 2026

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