PHPackages                             archict/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. [Security](/categories/security)
4. /
5. archict/firewall

AbandonedArchivedArchict-brick[Security](/categories/security)

archict/firewall
================

Control access to resources

v0.2.0(1y ago)05[5 PRs](https://github.com/Archict/firewall/pulls)MITPHPPHP &gt;= 8.2

Since May 18Pushed 1y ago1 watchersCompare

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

READMEChangelog (2)Dependencies (10)Versions (8)Used By (0)

Firewall
========

[](#firewall)

[![Tests](https://github.com/Archict/firewall/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/Archict/firewall/actions/workflows/tests.yml)

Control access to your resources

How to use
----------

[](#how-to-use)

The majority of the work is inside the config file `firewall.yml`:

```
providers:
  my_provider: \Class\Name\Of\My\User\Provider
access_control:
  - path: ^/admin # Path to match (a regex)
    provider: my_provider
    roles: [ "ADMIN" ] # Roles user need to have to see resources
    error: 404 # If user not authorized, then return this error code
  - path: ^/profile
    provider: my_provider
    roles: [ "USER" ]
    redirect_to: /login # If user not authorized, then return to this uri
```

Let's go in details!

### User provider

[](#user-provider)

To help firewall to get current user, you need to give it a User provider.

This Brick provides you the interface `\Archict\Firewall\UserProvider`:

```
