PHPackages                             codzo/middleware-authentication - 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. codzo/middleware-authentication

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

codzo/middleware-authentication
===============================

Slim 4 Middleware for authentication

044PHP

Since Nov 29Pushed 1y ago1 watchersCompare

[ Source](https://github.com/codzo/middleware-authentication)[ Packagist](https://packagist.org/packages/codzo/middleware-authentication)[ RSS](/packages/codzo-middleware-authentication/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Authenticate Through Middleware
===============================

[](#authenticate-through-middleware)

Dependency
----------

[](#dependency)

- Package `codzo/config`

Settings
--------

[](#settings)

Require following settings exposured to `codzo/config`

- `authentication.validator.classname`

    The classname of selected validator. If appointing multiple validators, using a comma to separate class names. The first validator successfully authenticated the use will provide an authentication identifier to app and end the process.

    Provide full class name with namespaces.

    Default value: `Codzo\Middleware\Authentication\Validator\SessionValidator`.
- `authentication.redirect.url`

    The redirect url when authentication failed.

    Default value: `/login`.

See validators for more setting options.

How to authenticate
-------------------

[](#how-to-authenticate)

This middleware will call **validators** to authenticate. A validator implements `IAuthenticationValidator` providing following functions:

- `isAuthenticated(Request $request=null) : bool`

    check if authenticated. If not, redirect to `/Login'
- `getAuthenticationIdentifer() : string`

    get the identifier. See validators for specific data returned.

Validator
---------

[](#validator)

Built-in validators:

### SessionValidator

[](#sessionvalidator)

Validate the data stored in session for authentication.

Settings:

- `authentication.sessionvalidator.session.varname`

    The name of the session data. This is the key name of `$_SESSION` variable.

    Example:

    With setting as of `LOGIN_UUID`, `$_SESSION ['LOGIN__UUID']` will be checked and returned.
- `authentication.sessionvalidator.session.value`

    The pattern of the expected identifier. If session data matches this pattern, current use will be considered as authenticated.

    Example: `.*` to match any string.

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance30

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity16

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/6d50c4f0fcf0cfd840aee71baebc79f441ea8f3a7bef4406fcd5fba97022d4cd?d=identicon)[neilfan](/maintainers/neilfan)

---

Top Contributors

[![neilfan](https://avatars.githubusercontent.com/u/709968?v=4)](https://github.com/neilfan "neilfan (16 commits)")

### Embed Badge

![Health badge](/badges/codzo-middleware-authentication/health.svg)

```
[![Health](https://phpackages.com/badges/codzo-middleware-authentication/health.svg)](https://phpackages.com/packages/codzo-middleware-authentication)
```

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[league/oauth2-google

Google OAuth 2.0 Client Provider for The PHP League OAuth2-Client

41721.2M118](/packages/league-oauth2-google)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)

PHPackages © 2026

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