PHPackages                             beebmx/kirby-patrol - 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. beebmx/kirby-patrol

ActiveKirby-plugin[Security](/categories/security)

beebmx/kirby-patrol
===================

Patrol for Kirby

1.3.0(8mo ago)981[1 issues](https://github.com/beebmx/kirby-patrol/issues)MITPHPPHP ^8.2CI passing

Since Jun 18Pushed 8mo ago2 watchersCompare

[ Source](https://github.com/beebmx/kirby-patrol)[ Packagist](https://packagist.org/packages/beebmx/kirby-patrol)[ RSS](/packages/beebmx-kirby-patrol/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (6)Versions (11)Used By (0)

[![Patrol Logo](https://github.com/beebmx/kirby-patrol/raw/main/assets/logo.svg?raw=true)](https://github.com/beebmx/kirby-patrol)

[![Build Status](https://camo.githubusercontent.com/b533ebe4f8c025a32e9ad19bd0f80c37699944fe1bbce3236047b6aa1bbab504/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f626565626d782f6b697262792d706174726f6c2f74657374732e796d6c3f6272616e63683d6d61696e)](https://github.com/beebmx/kirby-patrol/actions)[![Total Downloads](https://camo.githubusercontent.com/2f4e73cd194000bb2b62d548615179630907a62524f3161963fcf0556b366258/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f626565626d782f6b697262792d706174726f6c)](https://packagist.org/packages/beebmx/kirby-patrol)[![Latest Stable Version](https://camo.githubusercontent.com/e28334b6fb78d47689f640976b61924893f983c3ec410b952e28ea37b8d78991/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f626565626d782f6b697262792d706174726f6c)](https://packagist.org/packages/beebmx/kirby-patrol)[![License](https://camo.githubusercontent.com/7deba47a0f6e39fe34724097e31e6d257084994dd267d27db96ebbf45ce2bda6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f626565626d782f6b697262792d706174726f6c)](https://packagist.org/packages/beebmx/kirby-patrol)

Patrol for Kirby
================

[](#patrol-for-kirby)

An easy and customizable way to manage access to website pages according to the roles assigned to users within the Kirby panel interface.

---

Overview
--------

[](#overview)

- [1. Installation](#installation)
- [2. Usage](#usage)
- [3. Options](#options)
- [4. Roadmap](#roadmap)
- [5. License](#license)
- [6. Credits](#credits)

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

[](#installation)

### Download

[](#download)

Download and copy this repository to `/site/plugins/kirby-patrol`.

### Composer

[](#composer)

```
composer require beebmx/kirby-patrol

```

Usage
-----

[](#usage)

Out of the box, you don't need to do anything to start using (except for installation), but if you require customizing the default behavior, there are some options to personalize `Patrol`.

### Panel

[](#panel)

All users with panel access will see the new area and will be able to update the access to the pages on the website.

If you need to restrict this behavior, you can do so by adding the permission in the user YAML file:

```
title: Editor

permissions:
  beebmx.patrol:
    access: false
```

Note

The `access` is set to `true` by default

The pages displayed in the new panel area will be all the `site` childrens published (with status `listed` and `unlisted`) and two levels inside every page. If you need a specific collection of pages you can change it with the `query` option in your `config.php` file:

```
use Kirby\Cms\App;
use Kirby\Cms\Pages;
use Kirby\Cms\Site;

'beebmx.patrol' => [
    'content' => [
        'query' => function (Site $site, Pages $pages, App $kirby) {
            return $site->find('secure-page')->children()->listed();
        },
    ],
],
```

And if you need to update the `depth` of the pages displayed, update the `config.php` file:

```
'beebmx.patrol' => [
    'content' => [
        'depth' => 3,
    ],
],
```

Here's an example of `Patrol` view page:

[![Patrol panel example](https://raw.githubusercontent.com/beebmx/kirby-patrol/main/assets/patrol-panel.png)](https://raw.githubusercontent.com/beebmx/kirby-patrol/main/assets/patrol-panel.png)

### Frontend

[](#frontend)

When a logged-in user visits any page, `Patrol` will automatically validate the request. If the user has access to the visited page, they can normally view the content, but if not, an error page will be thrown with a `401` status code.

Warning

It's important that you use a logged-in user when the validation occurs; otherwise, an error will be thrown. If the default

### Middleware

[](#middleware)

Even when `Patrol` tries to validate a user, it's possible that behavior won't be enough for your own validation. In that case, you can customize and add additional restrictions to every page.

The middleware process is powered by [Middleware](https://github.com/beebmx/kirby-middleware), and you can use all features if you need to.

#### Closure middleware

[](#closure-middleware)

The easyest way to add additional validation is with `Closures`. Added this in the `config.php` file:

```
use Kirby\Http\Response;
use Beebmx\KirbyMiddleware\Request;

'beebmx.patrol' => [
    'permissions' => [
        'middleware' => [
            function (Request $request, Closure $next) {
                if(page($request->path())->is('secure-page')) {
                    return Response::redirect('login')
                }

                return $next($request);
            },
        ],
    ],
],
```

As you can see, the `Closure` requires two parameters: an `Request` called `$request` and a `Closure` called `$next`. The `$request` contains the stack of previous validations from Patrol and any other middleware triggered.

The second parameter `$next`, you should call it at the end of the process to proceed to the next validation with the `$request`.

Note

You can return a `Response::class` object. When you do that, `Patrol` will automatically send the request.

#### Class middleware

[](#class-middleware)

If your own validation is more complex for a simple `Closure`, you can use a custom class for that purpose:

```
'beebmx.patrol' => [
    'permissions' => [
        'middleware' => [
            MyCustomMiddleware::class,
        ],
    ],
],
```

And your class should look like:

```
use Beebmx\KirbyMiddleware\Request;
use Closure;
use Kirby\Cms\App;
use Kirby\Exception\ErrorPageException;

class MyCustomMiddleware
{
    public function handle(Request $request, Closure $next)
    {
        $kirby = App::instance();

        if ($kirby->site()->isDisabled()->toBool()) {
            return throw new ErrorPageException([
                'fallback' => 'Unauthorized',
                'httpCode' => 401,
            ]);
        }

        return $next($data);
    }
}
```

Your middleware logic should be inside the `handle` method; otherwise, the middleware will never be triggered.

Note

You can throw an exception `ErrorPageException::class` with your custom data in case you need it.

### Redirection

[](#redirection)

Sometimes you don't need an error in your website to display an error, in that cases you can make a redireccion:

```
'beebmx.patrol' => [
    'permissions' => [
        'redirect' => 'login',
    ],
],
```

As you can see, when a redirection is set, you don't need to customize an extra `middleware`.

### Utilities

[](#utilities)

You have utilities available to incorporate into your existing workflow:

#### User utilities

[](#user-utilities)

If you want to validate if a `user` has access to a given Page:

```
user()->can($page)
```

Note

Page can be a `string` or a `Kirby\Cms\Page` object

If you want to retrieve all the pages with access or without access

```
user()->patrol(bool)
```

Note

A `true` value returns all pages with access. A `false` value returns all pages without access.

#### Pages utility

[](#pages-utility)

If you want to know if a `pages` collection have access or not:

```
pages()->patrol(bool)
```

Note

A `true` value returns all pages with access. A `false` value returns all pages without access.

Options
-------

[](#options)

OptionDefaultTypeDescriptionbeebmx.patrol.enabledtrue`bool`Enable access in `Kirby Panel`beebmx.patrol.iconkeyhole`string`Icon displayed in `Kirby Panel`. Options available are: `flash` `keyhole` `police` `shield` `siren` `star` `user`beebmx.patrol.namePatrol`string`Set a `string` to display in the `Kirby Panel`.beebmx.patrol.content.columns4`int`Set how many `columns` will be displayed into the `Patrol` view.beebmx.patrol.content.depth2`int`Set the `depth` to dig into the `pages` collection.beebmx.patrol.content.directionasc`string`Set the sort `direction` of the content.beebmx.patrol.content.sorttitle`string`Set the `sort` value for the content.beebmx.patrol.content.querynull`?Closure`Use a specific query to display and validate by `Patrol`. It requires returning a collection of `pages`.beebmx.patrol.permissions.defaulttrue`bool`Set the `default` values of all the checkboxes when no patrol values are set.beebmx.patrol.permissions.enabledtrue`bool`Enable/Disable the default `middleware` functionality.beebmx.patrol.permissions.middleware\[\]`array`Additional middleware functionality.beebmx.patrol.permissions.redirectnull`?string`Disabled the default `middleware` functionality and changed it to redirect to a specific URL path.Warning

Since version `1.3.0`, `Patrol` changes the plugin prefix from `beebmx.kirby-patrol` to `beebmx.patrol`.

Here's an example of a full use of the options from the `config.php` file:

```
use Beebmx\KirbyMiddleware\Request;
use Closure;

'beebmx.patrol' => [
    'name' => 'Profiles',
    'icon' => 'shield',
    'content' => [
        'columns' => 4,
        'depth' => 3,
        'query' => function (Site $site, Pages $pages, Kirby $kirby) {
            return $site->find('private-content')->children()->listed();
        },
    ],
    'permissions' => [
        'redirect' => 'login',
        'default' => true,
        'middleware' => [
            function (Request $request, Closure $next) {
                if(page($request->path())->id() === 'super-secret-page') {
                    return throw new ErrorPageException([
                        'fallback' => 'Unauthorized',
                        'httpCode' => 401,
                    ]);
                }

                return $next($request);
            },
        ]
    ],
],
```

Roadmap
-------

[](#roadmap)

- Custom hooks
- Multilanguage support
- Guest support

License
-------

[](#license)

Licensed under the [MIT](LICENSE.md).

Credits
-------

[](#credits)

- Fernando Gutierrez [@beebmx](https://github.com/beebmx)
- [jonatanjonas](https://github.com/jonatanjonas) `logo`
- [All Contributors](../../contributors)

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance57

Moderate activity, may be stable

Popularity15

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~47 days

Recently: every ~106 days

Total

10

Last Release

264d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/434a3fd09c4701e824184e720b3d2fd97814ed8d1275417f6762c411bf146328?d=identicon)[beebmx](/maintainers/beebmx)

---

Top Contributors

[![beebmx](https://avatars.githubusercontent.com/u/2191576?v=4)](https://github.com/beebmx "beebmx (12 commits)")

---

Tags

kirby-pluginkirby4kirby5middlewaresecurityrolesUserskirbykirby-pluginkirby5kirby4

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/beebmx-kirby-patrol/health.svg)

```
[![Health](https://phpackages.com/badges/beebmx-kirby-patrol/health.svg)](https://phpackages.com/packages/beebmx-kirby-patrol)
```

###  Alternatives

[bnomei/kirby3-redirects

Setup performant HTTP Status Code Redirects from within the Kirby Panel

269.1k](/packages/bnomei-kirby3-redirects)[beebmx/kirby-env

Enable env variables to Kirby

2037.9k2](/packages/beebmx-kirby-env)[beebmx/kirby-courier

Courier offers a convenient and painless solution for creating emails tailored for your Kirby website.

403.0k2](/packages/beebmx-kirby-courier)[beebmx/kirby-db

Enable database support for Illuminate\\Database in Kirby

192.6k](/packages/beebmx-kirby-db)[wagnerwagner/merx

A toolkit to create online shops with Kirby

1152.7k](/packages/wagnerwagner-merx)[ayesh/stateless-csrf

Secret-key based state-less CSRF token generator and validator for PHP 8. State-less means you do not have to store the CSRF token in session or database.

3223.3k](/packages/ayesh-stateless-csrf)

PHPackages © 2026

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