PHPackages                             caridea/auth - 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. caridea/auth

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

caridea/auth
============

A shrimp of an authentication library

3.0.0(8y ago)05762Apache-2.0PHPPHP &gt;=7.1.0

Since Jun 3Pushed 8y ago1 watchersCompare

[ Source](https://github.com/libreworks/caridea-auth)[ Packagist](https://packagist.org/packages/caridea/auth)[ Docs](http://github.com/libreworks/caridea-auth)[ RSS](/packages/caridea-auth/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (5)Versions (10)Used By (2)

caridea-auth
============

[](#caridea-auth)

Caridea is a miniscule PHP application library. This shrimpy fellow is what you'd use when you just want some helping hands and not a full-blown framework.

[![](https://camo.githubusercontent.com/3a9d2bd9abd336c1541d254cd07f8dff935288ad4a0983294f0b3f572f5b0f4b/687474703a2f2f6c69627265776f726b732e636f6d2f636172696465612d3130302e706e67)](https://camo.githubusercontent.com/3a9d2bd9abd336c1541d254cd07f8dff935288ad4a0983294f0b3f572f5b0f4b/687474703a2f2f6c69627265776f726b732e636f6d2f636172696465612d3130302e706e67)

This is its authentication component. It provides a way to authenticate principals and store their identity. It will broadcast authentication events for any listeners. It works with any implementation of [PSR-7](http://www.php-fig.org/psr/psr-7/).

Included are three adapters for authentication through MongoDB, PDO, and X.509 client SSL certificates. You can easily write your own adapter for other authentication sources like IMAP, LDAP, or OAuth2.

[![Packagist](https://camo.githubusercontent.com/28ea2f4e7ea79b4ee7a94bc32775b442a343e6e27e91460655d6f28b7e68045e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636172696465612f617574682e737667)](https://packagist.org/packages/caridea/auth)[![Build Status](https://camo.githubusercontent.com/b1f4265ed98ab34359378e31ff91d796e3b6928c7bc6d85c0d183f5195c1549b/68747470733a2f2f7472617669732d63692e6f72672f6c69627265776f726b732f636172696465612d617574682e737667)](https://travis-ci.org/libreworks/caridea-auth)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/7ef79f78131f6061dda3a0a393fb2a82ff27f633069c9647ace981b70c2018f5/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6c69627265776f726b732f636172696465612d617574682f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/libreworks/caridea-auth/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/3c52a13b10e8ff11fde0ebd4964abae9a4fdee27c87cf3f23d2304bbba13a4e1/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6c69627265776f726b732f636172696465612d617574682f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/libreworks/caridea-auth/?branch=master)

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

[](#installation)

You can install this library using Composer:

```
$ composer require caridea/auth
```

- The master branch (version 3.x) of this project requires PHP 7.1 and depends on `caridea/event`, `caridea/session`, `psr/log`, and `psr/http-message`.
- Version 2.x of this project requires PHP 7.0 and depends on `caridea/event`, `caridea/session`, `psr/log`, and `psr/http-message`.
- Version 1.x of this project requires PHP 5.5 and depends on `caridea/event`, `caridea/session`, `psr/log`, and `psr/http-message`.

Compliance
----------

[](#compliance)

Releases of this library will conform to [Semantic Versioning](http://semver.org).

Our code is intended to comply with [PSR-1](http://www.php-fig.org/psr/psr-1/), [PSR-2](http://www.php-fig.org/psr/psr-2/), and [PSR-4](http://www.php-fig.org/psr/psr-4/). If you find any issues related to standards compliance, please send a pull request!

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

[](#documentation)

- Head over to [Read the Docs](http://caridea-auth.readthedocs.io/en/latest/)

Examples
--------

[](#examples)

Just a few quick examples.

### Login

[](#login)

```
// Let's say $session is a \Caridea\Session\Session, such as \Caridea\Session\NativeSession
// Let's say $publisher is a \Caridea\Event\Publisher, such as \Caridea\Container\Objects
$service = new \Caridea\Auth\Service($session, $publisher);

// Let's say $collection is a \MongoCollection
$adapter = new \Caridea\Auth\Adapter\Mongo($collection, 'username', 'password');

// Let's say $request is a \Psr\Http\Message\RequestInterface
if ($service->login($request, $adapter)) {
    $principal = $service->getPrincipal();
    $username = $principal->getUsername();
    $details = $principal->getDetails());

    // $details = [
    //    'id' => '1234567890',
    //    'ua' => 'Mozilla/5.0',
    //    'ip' => '192.168.1.1'
    // ];
}
```

Upon login, `Service` will broadcast a `Caridea\Auth\Event\Login` if `$publisher` has been set.

### Resume

[](#resume)

```
// Let's say $session is a \Caridea\Session\Session, such as \Caridea\Session\NativeSession
// Let's say $publisher is a \Caridea\Event\Publisher, such as \Caridea\Container\Objects
$service = new \Caridea\Auth\Service($session, $publisher);

if ($service->resume()) {
    $principal = $service->getPrincipal();
}
```

Upon resume, `Service` will broadcast a `Caridea\Auth\Event\Resume` if `$publisher` has been set.

### Logout

[](#logout)

```
// Let's say $session is a \Caridea\Session\Session, such as \Caridea\Session\NativeSession
// Let's say $publisher is a \Caridea\Event\Publisher, such as \Caridea\Container\Objects
$service = new \Caridea\Auth\Service($session, $publisher);

// Let's say $collection is a \MongoCollection
$adapter = new \Caridea\Auth\Adapter\Mongo($collection, 'username', 'password');

if ($service->logout()) {
    // anonymous!
}
```

Upon login, `Service` will broadcast a `Caridea\Auth\Event\Logout` if `$publisher` has been set.

### Login Timeout

[](#login-timeout)

A component has been included, the `TimeoutListener` which can be registered in a `Caridea\Event\Publisher`.

It listens for `Caridea\Auth\Event\Resume` and will log out a user if an authenticated session has either gone on too long or has been idle for too long.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity64

Established project with proven stability

 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 ~118 days

Recently: every ~161 days

Total

9

Last Release

3054d ago

Major Versions

0.1.0 → 1.0.02016-03-21

1.x-dev → 2.0.02016-03-23

2.1.x-dev → 3.0.02018-01-06

PHP version history (3 changes)0.1.0PHP &gt;=5.5.0

2.0.0PHP &gt;=7.0.0

3.0.0PHP &gt;=7.1.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/659262eac941ffe4795493834425fc9a2369c2c9df3cc565ed4194f1d37be934?d=identicon)[doublecompile](/maintainers/doublecompile)

---

Top Contributors

[![doublecompile](https://avatars.githubusercontent.com/u/4267230?v=4)](https://github.com/doublecompile "doublecompile (28 commits)")

---

Tags

authAuthenticationauthenticate

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/caridea-auth/health.svg)

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

###  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)[google/auth

Google Auth Library for PHP

1.4k272.7M162](/packages/google-auth)[tymon/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

11.5k49.1M350](/packages/tymon-jwt-auth)[auth0/auth0-php

PHP SDK for Auth0 Authentication and Management APIs.

40820.2M68](/packages/auth0-auth0-php)[kreait/firebase-tokens

A library to work with Firebase tokens

24040.8M14](/packages/kreait-firebase-tokens)[aura/auth

Provides a unified interface to authenticate a user with local or remote authentication systems.

138238.7k12](/packages/aura-auth)

PHPackages © 2026

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