diff --git a/README.md b/README.md index dc296cf..8f03722 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,110 @@ [![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 you resources +Control access to your resources + +## How to use + +The majority of the work is inside the config file `firewall.yml`: + +```yaml +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 + +To help firewall to get current user, you need to give it a User provider. + +This Brick provides you the interface `\Archict\Firewall\UserProvider`: + +```php +