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

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

codemonster-ru/auth
===================

Framework-agnostic authentication primitives for Annabel applications.

v1.0.1(today)076↑2347.4%MITPHPPHP &gt;=8.2

Since Jun 10Pushed todayCompare

[ Source](https://github.com/codemonster-ru/auth)[ Packagist](https://packagist.org/packages/codemonster-ru/auth)[ Docs](https://github.com/codemonster-ru/auth)[ RSS](/packages/codemonster-ru-auth/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (10)Versions (3)Used By (0)

codemonster-ru/auth
===================

[](#codemonster-ruauth)

Framework-agnostic authentication primitives for Annabel applications.

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

[](#installation)

```
composer require codemonster-ru/auth
```

Concepts
--------

[](#concepts)

- `AuthenticatableInterface` describes a user object.
- `UserProviderInterface` retrieves and validates users.
- `PasswordHasherInterface` hashes and verifies passwords.
- `AuthorizerInterface` checks abilities and policies.
- `SessionGuard` stores the authenticated user id in `codemonster-ru/session`.
- `Authenticate` middleware rejects guests with `401` or redirects them.
- `Authorize` middleware rejects requests that fail a gate ability check.

Example
-------

[](#example)

```
use Codemonster\Auth\Guards\SessionGuard;
use Codemonster\Auth\Hashing\NativePasswordHasher;
use Codemonster\Auth\Providers\ArrayUserProvider;

$hasher = new NativePasswordHasher();
$provider = new ArrayUserProvider([
    new User(1, 'admin@example.com', $hasher->make('secret')),
], $hasher);

$guard = new SessionGuard($provider, session());

if ($guard->attempt(['email' => 'admin@example.com', 'password' => 'secret'])) {
    echo $guard->id(); // 1
}

$guard->logout(); // Invalidates the session by default.
```

`ArrayUserProvider` is intentionally small. Production applications can provide their own database-backed implementation of `UserProviderInterface`.

Authorization
-------------

[](#authorization)

```
use Codemonster\Auth\Authorization\Gate;

$gate = new Gate($guard);
$gate->define('posts.update', fn($user, $post) => $user?->getAuthIdentifier() === $post->owner_id);

if ($gate->allows('posts.update', $post)) {
    // ...
}
```

In Annabel routes, the `can` middleware alias can read route parameters exposed by the HTTP kernel:

```
router()
    ->get('/posts/{post}', [PostController::class, 'show'])
    ->middleware('can:posts.view,post');
```

Database users
--------------

[](#database-users)

`DatabaseUserProvider` retrieves users through `codemonster-ru/database`'s `ConnectionInterface`:

```
use Codemonster\Auth\Database\DatabaseUserProvider;

$provider = new DatabaseUserProvider(
    db(),
    new NativePasswordHasher(),
    table: 'users',
    identifierColumn: 'id',
    passwordColumn: 'password',
    credentialKey: 'email',
);
```

Annabel integration
-------------------

[](#annabel-integration)

`codemonster-ru/annabel` registers the auth services through `AuthServiceProvider`. Applications can use `auth()` and `user()` helpers, and protect routes with `Codemonster\Auth\Middleware\Authenticate` and `Codemonster\Auth\Middleware\Authorize`.

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance100

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity47

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

Total

2

Last Release

0d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/33142935?v=4)[Kirill Kolesnikov](/maintainers/KolesnikovKirill)[@KolesnikovKirill](https://github.com/KolesnikovKirill)

---

Top Contributors

[![KolesnikovKirill](https://avatars.githubusercontent.com/u/33142935?v=4)](https://github.com/KolesnikovKirill "KolesnikovKirill (2 commits)")

---

Tags

phpauthAuthenticationsessioncodemonsterannabel

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[ellaisys/aws-cognito

AWS Cognito package that allows Auth and other related features using the AWS SDK for PHP

120242.9k1](/packages/ellaisys-aws-cognito)[kinde-oss/kinde-auth-php

Kinde PHP SDK for authentication

2280.2k3](/packages/kinde-oss-kinde-auth-php)[maicol07/flarum-ext-sso

SSO for Flarum

468.7k](/packages/maicol07-flarum-ext-sso)

PHPackages © 2026

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