PHPackages                             maksimovic/slim-oauth2-middleware - 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. maksimovic/slim-oauth2-middleware

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

maksimovic/slim-oauth2-middleware
=================================

OAuth2 middleware for use within a Slim Framework API

5.0.0(3mo ago)04.3k1MITPHPPHP ^8.1CI passing

Since Jul 23Pushed 3mo agoCompare

[ Source](https://github.com/maksimovic/slim-oauth2-middleware)[ Packagist](https://packagist.org/packages/maksimovic/slim-oauth2-middleware)[ RSS](/packages/maksimovic-slim-oauth2-middleware/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (3)Dependencies (18)Versions (25)Used By (1)

Chadicus\\Slim\\OAuth2\\Middleware
==================================

[](#chadicusslimoauth2middleware)

> **Fork Notice:** This is a maintained fork of the abandoned [`chadicus/slim-oauth2-middleware`](https://github.com/chadicus/slim-oauth2-middleware) package. Updated for PHP 8.1+ and PSR-15.

[![License](https://camo.githubusercontent.com/734508b359fe427e61876360db5d0c09f026c3a81629ce7688d94f2a31989e01/68747470733a2f2f706f7365722e707567782e6f72672f6d616b73696d6f7669632f736c696d2d6f61757468322d6d6964646c65776172652f6c6963656e7365)](https://packagist.org/packages/maksimovic/slim-oauth2-middleware)

PSR-15 middleware for using [OAuth2 Server](http://bshaffer.github.io/oauth2-server-php-docs/) within any PSR-15 compatible framework, including [Slim 4](http://www.slimframework.com/).

Requirements
------------

[](#requirements)

PHP 8.1 or later.

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

[](#installation)

```
composer require maksimovic/slim-oauth2-middleware
```

Example usage
-------------

[](#example-usage)

```
use Chadicus\Slim\OAuth2\Middleware\Authorization;
use OAuth2;
use OAuth2\Storage;
use OAuth2\GrantType;

$storage = new Storage\Memory([
    'client_credentials' => [
        'administrator' => ['client_id' => 'administrator', 'client_secret' => 'password', 'scope' => 'superUser'],
    ],
]);

$server = new OAuth2\Server(
    $storage,
    ['access_lifetime' => 3600],
    [new GrantType\ClientCredentials($storage)]
);

$auth = new Authorization($server, $container);

// Slim 4
$app->get('/foos', $handler)->add($auth);
$app->post('/foos', $handler)->add($auth->withRequiredScope(['superUser']));
```

`$container` must be either an `ArrayAccess` or expose a `set($key, $value)` method (e.g. PHP-DI). The decoded access token is stored under the `'token'` key on success and added to the request as the `oauth2-token` attribute.

Development
-----------

[](#development)

```
composer install
composer test
composer test:coverage
composer cs-check
```

License
-------

[](#license)

MIT

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance80

Actively maintained with recent releases

Popularity24

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity82

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 92% 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 ~171 days

Recently: every ~11 days

Total

24

Last Release

105d ago

Major Versions

v0.2.3 → v1.0.02016-02-04

v1.x-dev → v3.0.02016-05-22

v3.4.0 → v4.0.12026-03-13

v3.4.1 → v4.0.22026-03-18

v4.0.2 → v5.x-dev2026-04-28

PHP version history (6 changes)v0.1.0PHP ~5.4 || ~7.0

v1.0.0PHP ~5.5 || ~7.0

v3.0.0PHP ~5.6 || ~7.0

v3.1.1PHP ^5.6 || ^7.0

v3.3.0PHP ^5.6 || ^7.0 || ^8.0

v4.0.1PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/d43e10a649dca578689bc02aa4089e26c0d26b1a2f3640dda458973e55adcf10?d=identicon)[maksimovic](/maintainers/maksimovic)

---

Top Contributors

[![chadicus](https://avatars.githubusercontent.com/u/1182337?v=4)](https://github.com/chadicus "chadicus (127 commits)")[![maksimovic](https://avatars.githubusercontent.com/u/1126226?v=4)](https://github.com/maksimovic "maksimovic (9 commits)")[![markfrydrych](https://avatars.githubusercontent.com/u/20677808?v=4)](https://github.com/markfrydrych "markfrydrych (1 commits)")[![soren121](https://avatars.githubusercontent.com/u/295939?v=4)](https://github.com/soren121 "soren121 (1 commits)")

---

Tags

middlewareslimoauth2

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/maksimovic-slim-oauth2-middleware/health.svg)

```
[![Health](https://phpackages.com/badges/maksimovic-slim-oauth2-middleware/health.svg)](https://phpackages.com/packages/maksimovic-slim-oauth2-middleware)
```

###  Alternatives

[cakephp/cakephp

The CakePHP framework

8.9k20.0M1.8k](/packages/cakephp-cakephp)[google/auth

Google Auth Library for PHP

1.4k302.1M240](/packages/google-auth)[cakephp/authentication

Authentication plugin for CakePHP

1214.3M118](/packages/cakephp-authentication)[typo3/cms

TYPO3 CMS is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.

1.2k1.9M122](/packages/typo3-cms)[chadicus/slim-oauth2-middleware

OAuth2 middleware for use within a Slim Framework API

48423.2k1](/packages/chadicus-slim-oauth2-middleware)[typo3/cms-core

TYPO3 CMS Core

3313.6M5.6k](/packages/typo3-cms-core)

PHPackages © 2026

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