PHPackages                             jasny/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. [HTTP &amp; Networking](/categories/http)
4. /
5. jasny/auth

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

jasny/auth
==========

Authentication, authorization and access control for Slim Framework and other PHP micro-frameworks

v2.2.1(1y ago)11816.4k↓50%34[1 issues](https://github.com/jasny/auth/issues)1MITPHPPHP &gt;=8.2.0

Since Oct 7Pushed 1y ago11 watchersCompare

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

READMEChangelog (7)Dependencies (15)Versions (29)Used By (1)

[![jasny-banner](https://user-images.githubusercontent.com/100821/62123924-4c501c80-b2c9-11e9-9677-2ebc21d9b713.png)](https://user-images.githubusercontent.com/100821/62123924-4c501c80-b2c9-11e9-9677-2ebc21d9b713.png)

Jasny Auth
==========

[](#jasny-auth)

[![PHP](https://github.com/jasny/auth/actions/workflows/php.yml/badge.svg)](https://github.com/jasny/auth/actions/workflows/php.yml)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/92115d99b085036b85916bccf3ceea81da38465af24cdb3dcba573b92f12bd51/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a61736e792f617574682f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/jasny/auth/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/abbfbc77ee27ffc6f7ec8da13c4c845cabd73c5bbe1ed172203a3a71a7eed00f/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a61736e792f617574682f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/jasny/auth/?branch=master)[![Packagist Stable Version](https://camo.githubusercontent.com/865533d5fa9a128e3264767732baed45817213c9418732d50a8b351145bed6bb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a61736e792f617574682e737667)](https://packagist.org/packages/jasny/auth)[![Packagist License](https://camo.githubusercontent.com/80d646eb5b2868bad99ecd635cd69bf9dcd423b0370d9e1b4c454eca155a25e7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6a61736e792f617574682e737667)](https://packagist.org/packages/jasny/auth)

Authentication, authorization and access control for [Slim Framework](https://www.slimframework.com/) and other PHP micro-frameworks.

**Features**

- Multiple [authorization strategies](https://www.jasny.net/auth/setup/roles), like groups (for acl) and levels.
- Authorization [context](https://www.jasny.net/auth/setup/context) (eg. "is the user an *admin* of this *team*?").
- PSR-14 [events](https://www.jasny.net/auth/authentication#events) for login and logout.
- PSR-15 [middleware](https://www.jasny.net/auth/middleware) for access control.
- [Session invalidation](https://www.jasny.net/auth/authentication#session-invalidation), explicit or implicit (eg. after password change).
- [Multi-factor authentication](https://www.jasny.net/auth/mfa/) support.
- [JWT](https://www.jasny.net/auth/sessions/jwt) and [Bearer authentication](https://www.jasny.net/auth/sessions/bearer)support.
- [Confirmation tokens](https://www.jasny.net/auth/confirmation/index) for sign up confirmation and forgot-password.
- PSR-3 [logging](https://www.jasny.net/auth/logging) of interesting events.
- Customizable to meet the requirements of your application.

---

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

[](#installation)

Install using composer

```
composer require jasny/auth

```

Usage
-----

[](#usage)

`Auth` is a composition class. It takes an *authz*, *storage*, and optionally a *confirmation* service.

```
use Jasny\Auth\Auth;
use Jasny\Auth\Authz\Levels;

$levels = new Levels(['user' => 1, 'moderator' => 10, 'admin' => 100]);
$auth = new Auth($levels, new AuthStorage());

session_start();
$auth->initialize();

// Later...
if (!$auth->is('admin')) {
    http_response_code(403);
    echo "Access denied";
    exit();
}
```

The `Auth` service isn't usable until it's initialized. This should be done after the session is started.

```
session_start();
$auth->initialize();
```

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

[](#documentation)

- [Home](https://www.jasny.net/auth/)
- [Setup](https://www.jasny.net/auth/setup)
    - [Roles](https://www.jasny.net/auth/setup/roles)
    - [Storage](https://www.jasny.net/auth/setup/storage)
    - [User](https://www.jasny.net/auth/setup/user)
    - [Context](https://www.jasny.net/auth/setup/context)
- [Authentication](https://www.jasny.net/auth/authentication)
- [Authorization](https://www.jasny.net/auth/authorization)
- [Sessions](https://www.jasny.net/auth/sessions/)
    - [JWT](https://www.jasny.net/auth/sessions/jwt)
    - [Bearer](https://www.jasny.net/auth/sessions/bearer)
- [Middleware](https://www.jasny.net/auth/middleware.md) (for access control)
- [MFA](https://www.jasny.net/auth/mfa) (Multi-factor authentication)
    - [TOTP](https://www.jasny.net/auth/mfa/totp) *(aka Google authenticator)*
- [Confirmation](https://www.jasny.net/auth/confirmation)
    - [Random token](https://www.jasny.net/auth/confirmation/token)
    - [Hashids](https://www.jasny.net/auth/confirmation/hashids)
    - Examples
        - [Signup](https://www.jasny.net/auth/confirmation/examples/signup)
        - [Forgot password](https://www.jasny.net/auth/confirmation/examples/forgot_password)
- [Logging](https://www.jasny.net/auth/logging)

###  Health Score

50

—

FairBetter than 96% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity42

Moderate usage in the ecosystem

Community23

Small or concentrated contributor base

Maturity86

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 97.9% 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 ~157 days

Recently: every ~398 days

Total

24

Last Release

626d ago

Major Versions

v1.0.1 → v2.0.0-beta12019-12-04

PHP version history (4 changes)v1.0.0-beta1PHP &gt;=5.4.0

v1.0.0PHP &gt;=5.6.0

v2.0.0-beta1PHP &gt;=7.4.0

v2.2.1PHP &gt;=8.2.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/3379a93d51305df325df9045e1a8b205d195e4e8c01312dff53a000ee79002eb?d=identicon)[jasny](/maintainers/jasny)

---

Top Contributors

[![jasny](https://avatars.githubusercontent.com/u/100821?v=4)](https://github.com/jasny "jasny (191 commits)")[![Minstel](https://avatars.githubusercontent.com/u/6154708?v=4)](https://github.com/Minstel "Minstel (2 commits)")[![SergeAx](https://avatars.githubusercontent.com/u/3264530?v=4)](https://github.com/SergeAx "SergeAx (1 commits)")[![Turv](https://avatars.githubusercontent.com/u/112819?v=4)](https://github.com/Turv "Turv (1 commits)")

---

Tags

authenticationauthorizationphppsr-15slim-frameworkslim3psr-7jwtauthslimpsr-15

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[tuupola/slim-basic-auth

PSR-7 and PSR-15 HTTP Basic Authentication Middleware

4442.0M26](/packages/tuupola-slim-basic-auth)[jimtools/jwt-auth

PSR-15 JWT Authentication middleware, A replacement for tuupola/slim-jwt-auth

20142.3k3](/packages/jimtools-jwt-auth)[phpro/http-tools

HTTP tools for developing more consistent HTTP implementations.

28137.8k](/packages/phpro-http-tools)[sunrise/http-router

A powerful solution as the foundation of your project.

16249.8k10](/packages/sunrise-http-router)[mezzio/mezzio-authentication-oauth2

OAuth2 (server) authentication middleware for Mezzio and PSR-7 applications.

28483.0k2](/packages/mezzio-mezzio-authentication-oauth2)[mezzio/mezzio-authentication

Authentication middleware for Mezzio and PSR-7 applications

121.6M26](/packages/mezzio-mezzio-authentication)

PHPackages © 2026

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