Skip to content

Repository files navigation

PSR-15 HTTP Cookie-based Auth Middleware

A single-file PSR-15 Middleware class that implements cookie-based gatekeeping on a PHP app in a single file.

Also provides a completely optional CakePHP plugin wrapper.

Usage

  1. From your PHP project, run composer require beporter/betablockermiddleware.

From here, the process diverges a bit depending on the host application.

General

  1. Wherever your app defines the Middlware stack,
  2. use Beporter\BetaBlockerMiddleware\Middleware\BetaBlockerMiddleware;
  3. $yourMiddlewareQueue->add(new BetaBlockerMiddleware(['cookie_value' => 'some pass']));

CakePHP

  1. Run bin/cake plugin load beporter/betablockermiddleware.

  2. Review the settings that were added to config/plugins.php. In particular, make sure the ['middleware' => true] key is set.

  3. Add at least the following key to your config/app.php:

    'BetaBlockerMiddleware' => [
        'cookie_value' => 'some password you want to give people',
    ],

Optional config keys

'BetaBlockerMiddleware' => [
    'expiration' => '+1 month',
    'redirect_url' => 'https://your.app.com/some/specific/destination',
    'beta_form' => '<form ...>override the password entry page here</form>',
],

Requirements

  • PHP v7.4+
  • A PSR-7 / PSR-15 compatible http request handling stack.

Contributing

Code of Conduct

Participation with this project requires compliance with our code of conduct.

Reporting Issues

Please use GitHub Isuses for listing any known defects or issues.

Development

Please fork this repository, create a new topic branch, and submit a pull request for your work.

Setup

TODO

License

MIT

Copyright

Copyright © 2026 Brian Porter

About

A single-file PSR-15 Middleware class that implements http basic auth gatekeeping on a PHP app.

Topics

Resources

Code of conduct

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages