PHPackages                             dflydev/stack-firewall - 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. dflydev/stack-firewall

ActiveLibrary

dflydev/stack-firewall
======================

Firewall Stack middleware

59.4k2[2 PRs](https://github.com/dflydev/dflydev-stack-firewall/pulls)2PHP

Since Jun 28Pushed 7y ago1 watchersCompare

[ Source](https://github.com/dflydev/dflydev-stack-firewall)[ Packagist](https://packagist.org/packages/dflydev/stack-firewall)[ RSS](/packages/dflydev-stack-firewall/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (2)

Firewall Authentication Middleware
==================================

[](#firewall-authentication-middleware)

A [Stack](http://stackphp.com/) middleware providing a simple, configurable firewall concept for [STACK-2 Authentication](http://stackphp.com/specs/STACK-2/) compatible middlewares.

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

[](#installation)

Through [Composer](http://getcomposer.org) as [dflydev/stack-firewall](https://packagist.org/packages/dflydev/stack-firewall).

Usage
-----

[](#usage)

The Firewall middleware is a thin layer over \[dflydev/stack-authentication\]\[4\] based STACK-2 Authentication middlewares.

A **firewall** is defined as an array of associatve arrays representing paths for which an authentication middleware should be concerned.

If a requested path does not match a firewalled path, the firewall delegates the request to the next layer immediately.

If a requested path matches and authentication is missing or invalid and anonymous requests are allowed, the request is allowed through the firewall without setting the `stack.authn.token`.

If a requested path matches and authentication is missing or invalid and anonymous requests are NOT allowed, the firewall will challenge immediately.

If no firewall is defined, the assumed configuration is:

```
[['path' => '/']]

```

This effectively means that by default the firewall will match all requests and will not allow anonymous requests resulting in returning a challenge.

```
