PHPackages                             ediazaro/filament-access-control - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. ediazaro/filament-access-control

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

ediazaro/filament-access-control
================================

Admin user, role and permission management for Laravel Filament

v4.0.0(6mo ago)03MITPHPPHP ^8.2|^8.3|^8.4

Since Nov 3Pushed 6mo agoCompare

[ Source](https://github.com/ediazaro/filament-access-control)[ Packagist](https://packagist.org/packages/ediazaro/filament-access-control)[ Docs](https://github.com/ediazaro/filament-access-control)[ GitHub Sponsors](https://github.com/chiiya)[ RSS](/packages/ediazaro-filament-access-control/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (7)Versions (2)Used By (0)

[![filament-access-control](https://user-images.githubusercontent.com/15029301/155413160-9ba82064-3436-414f-a556-a0bff61528a0.png)](https://user-images.githubusercontent.com/15029301/155413160-9ba82064-3436-414f-a556-a0bff61528a0.png)

Filament Access Control
=======================

[](#filament-access-control)

[![Latest Version on Packagist](https://camo.githubusercontent.com/1b51988ce23d1a7f82b121e87d752b1f93f2ab215a0f0d9c6bca1b412bc0a23e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6368696979612f66696c616d656e742d6163636573732d636f6e74726f6c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/chiiya/filament-access-control)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/6f035603df1d86f24c7b870c864f003450f018b3ce7877545f77a0dd11b9aaf4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6368696979612f66696c616d656e742d6163636573732d636f6e74726f6c2f6c696e743f6c6162656c3d636f64652532307374796c65)](https://github.com/chiiya/filament-access-control/actions?query=workflow%3Alint+branch%3Amaster)[![Total Downloads](https://camo.githubusercontent.com/1dcbca2cfb038eca867381767111ebc17bf50a7a76d8f1361c28ab50c672100c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6368696979612f66696c616d656e742d6163636573732d636f6e74726f6c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/chiiya/filament-access-control)

Opinionated setup for managing admin users, roles and permissions within [Laravel Filament](https://github.com/laravel-filament/filament)

Features
--------

[](#features)

- Separate database table for filament admin users (separate model, separate guard, separate password broker)
- Uses [spatie/laravel-permission](https://github.com/spatie/laravel-permission) for roles and permissions
- Fully localized
- CRUD resources for admin users, roles and permissions
- Admin users *may* belong to **one** role
- Admin users can have direct permissions or indirect permissions through their role
- When creating admin users through the admin interface, no password is specified. Instead, the user receives an email prompting them to set their password
- Optional account expiry for admin users. Expired accounts are no longer able to log in
- Optional email based two-factor authentication.

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

[](#installation)

1. Install the package via composer:

```
composer require chiiya/filament-access-control
```

2. Update your Filament Panel ServiceProvider and register the plugin:

```
use Chiiya\FilamentAccessControl\FilamentAccessControlPlugin;

return $panel
    ->default()
    ->id('admin')
    ->path('admin')
    ->plugin(FilamentAccessControlPlugin::make())
```

You may remove any calls to `login()` or other methods that configure the authentication process, since the plugin takes care of that.

3. Publish the migrations and config, then run the migrations. Make sure you also publish and run the [spatie/laravel-permission](https://github.com/spatie/laravel-permission) migrations if you haven't done so yet.

```
php artisan vendor:publish --tag="filament-access-control-migrations"
php artisan vendor:publish --tag="filament-access-control-config"
php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider"
php artisan migrate
```

4. To seed the necessary base data (role &amp; permissions), run `php artisan filament-access-control:install`or call the `Chiiya\FilamentAccessControl\Database\Seeders\FilamentAccessControlSeeder` seeder in your database seeder.
5. Create an admin user using `php artisan filament-access-control:user`. If you create users programmatically (e.g. in your database seeder), make sure to assign them the `super-admin` role if you want them to be able to access the role and user management.

Optionally, you can publish the translations with:

```
php artisan vendor:publish --tag="filament-access-control-translations"
```

Optionally, you can publish the views with:

```
php artisan vendor:publish --tag="filament-access-control-views"
```

Usage
-----

[](#usage)

### Authorizing Resources, Pages &amp; Actions

[](#authorizing-resources-pages--actions)

#### Authorizing Resources

[](#authorizing-resources)

To authorize access to resources, use policies as described in the [Filament documentation](https://filamentphp.com/docs/2.x/admin/resources#authorization).

```
class ProductPolicy
{
    public function viewAny(FilamentUser $user): bool
    {
        return $user->can('products.view');
    }

    // ...
}
```

#### Authorizing Pages

[](#authorizing-pages)

This package comes with a simple trait that you can use to authorize access to custom pages based on a permission.

```
use Chiiya\FilamentAccessControl\Traits\AuthorizesPageAccess;

class MyPage extends Page
{
    use AuthorizesPageAccess;

    public static string $permission = 'my-page.view';

    public function mount(): void
    {
        static::authorizePageAccess();
    }
}
```

#### Authorizing Actions

[](#authorizing-actions)

One way to authorize actions is to use the `visible()` method:

```
ButtonAction::make('exports')
    ->visible(fn () => Filament::auth()->user()->can('exports.view'))
```

### Localizing Role &amp; Permission Names

[](#localizing-role--permission-names)

Roles and permissions should have names that make them easy to use in code (e.g. `admin-users.update`). For the admin you may however wish to localize them or make them more readable. You can do so by simply adding a JSON translation entry for the given role or permission name (e.g. `lang/en.json`):

```
{
    "admin-users.update": "Admin Users → Edit"
}
```

### Feature: Account Expiry

[](#feature-account-expiry)

With the optional account expiry feature, all accounts require an expiration date. When accounts are expired, they can no longer log in. To enable the account expiry feature, enable the feature flag in the config file:

```
'features' => [
    \Chiiya\FilamentAccessControl\Enumerators\Feature::ACCOUNT_EXPIRY,
],
```

You will also need to add the `EnsureAccountIsNotExpired` middleware to your filament auth middleware config in your panel service provider:

```
use Chiiya\FilamentAccessControl\Http\Middleware\EnsureAccountIsNotExpired;

...
->authMiddleware([
    Authenticate::class,
    EnsureAccountIsNotExpired::class,
]);
```

### Feature: Two-Factor Authentication

[](#feature-two-factor-authentication)

With the optional two-factor authentication feature, users must enter a verification code sent via email upon login. To enable the two-factor authentication feature, enable the feature flag in the config file:

```
'features' => [
    \Chiiya\FilamentAccessControl\Enumerators\Feature::TWO_FACTOR,
],
```

### Custom User Model

[](#custom-user-model)

To use your own custom user model for the admin (instead of `Chiiya\FilamentAccessControl\Models\FilamentUser`), point the value of `user_model` in the `filament-access-control` config file to your own model.

```
'user_model' => CustomFilamentUser::class,
```

Please make sure that your model either extends the `FilamentUser` base case or implements the `Chiiya\FilamentAccessControl\Contracts\AccessControlUser` interface.

```
use Chiiya\FilamentAccessControl\Models\FilamentUser;
use Chiiya\FilamentAccessControl\Contracts\AccessControlUser;
use Filament\Models\Contracts\FilamentUser as FilamentUserInterface;
use Filament\Models\Contracts\HasName;
use Illuminate\Foundation\Auth\User as Authenticatable;

class CustomFilamentUser extends FilamentUser
{
    // ...
}

// Or alternatively
class CustomFilamentUser extends Authenticatable implements AccessControlUser, FilamentUserInterface, HasName
{
    // ...
}
```

### Extending Resources

[](#extending-resources)

To extend the resources used for managing admin users, roles and permissions, you can adjust the `resources` config value:

```
    /*
    |--------------------------------------------------------------------------
    | Resources
    |--------------------------------------------------------------------------
    | Resources used for managing users, roles and permissions.
    */
    'resources' => [
        'user' => FilamentUserResource::class,
        'role' => RoleResource::class,
        'permission' => PermissionResource::class,
    ]
```

The easiest way to extend the resources is to create your own resource classes that extend the default ones, and overwrite the following methods:

```
    public static function insertBeforeFormSchema(): array
    {
        return [];
    }

    public static function insertAfterFormSchema(): array
    {
        return [];
    }

    public static function insertBeforeTableSchema(): array
    {
        return [];
    }

    public static function insertAfterTableSchema(): array
    {
        return [];
    }

```

Screenshots
-----------

[](#screenshots)

[![Screenshot of Admin Users - View](./art/admin_users_view.png)](./art/admin_users_view.png)[![Screenshot of Roles - Edit](./art/roles_edit.png)](./art/roles_edit.png)[![Screenshot of Account Expired](./art/account_expired.png)](./art/account_expired.png)[![Screenshot of Two-Factor Authentication](./art/two_factor.png)](./art/two_factor.png)

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance68

Regular maintenance activity

Popularity3

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 63.1% 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

Unknown

Total

1

Last Release

187d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/97184fa8b835bc3a28d4a7cc9118f778ab9cdd702ad0b7c97aa60b2134b64e9f?d=identicon)[ediazaro](/maintainers/ediazaro)

---

Top Contributors

[![chiiya](https://avatars.githubusercontent.com/u/15029301?v=4)](https://github.com/chiiya "chiiya (70 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (18 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (12 commits)")[![bashgeek](https://avatars.githubusercontent.com/u/4669888?v=4)](https://github.com/bashgeek "bashgeek (2 commits)")[![JemCdo](https://avatars.githubusercontent.com/u/40404495?v=4)](https://github.com/JemCdo "JemCdo (1 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (1 commits)")[![magarrent](https://avatars.githubusercontent.com/u/6561770?v=4)](https://github.com/magarrent "magarrent (1 commits)")[![shibomb](https://avatars.githubusercontent.com/u/958471?v=4)](https://github.com/shibomb "shibomb (1 commits)")[![stephenjude](https://avatars.githubusercontent.com/u/31182887?v=4)](https://github.com/stephenjude "stephenjude (1 commits)")[![vzool](https://avatars.githubusercontent.com/u/4952736?v=4)](https://github.com/vzool "vzool (1 commits)")[![ediazaro](https://avatars.githubusercontent.com/u/159196692?v=4)](https://github.com/ediazaro "ediazaro (1 commits)")[![GeminiDev1](https://avatars.githubusercontent.com/u/48183390?v=4)](https://github.com/GeminiDev1 "GeminiDev1 (1 commits)")[![halowahyudi](https://avatars.githubusercontent.com/u/102675086?v=4)](https://github.com/halowahyudi "halowahyudi (1 commits)")

---

Tags

laravelrolespermissionsfilamentchiiyafilament-access-control

### Embed Badge

![Health badge](/badges/ediazaro-filament-access-control/health.svg)

```
[![Health](https://phpackages.com/badges/ediazaro-filament-access-control/health.svg)](https://phpackages.com/packages/ediazaro-filament-access-control)
```

###  Alternatives

[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[spatie/laravel-permission

Permission handling for Laravel 12 and up

12.9k89.8M1.0k](/packages/spatie-laravel-permission)[chiiya/filament-access-control

Admin user, role and permission management for Laravel Filament

21847.2k](/packages/chiiya-filament-access-control)[wnikk/laravel-access-rules

Simple system of ACR (access control rules) for Laravel, with roles, groups, unlimited inheritance and possibility of multiplayer use.

103.6k1](/packages/wnikk-laravel-access-rules)

PHPackages © 2026

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