PHPackages                             aiarmada/filament-authz - 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. aiarmada/filament-authz

ActiveLibrary

aiarmada/filament-authz
=======================

Filament v5 permissions suite powered by Spatie laravel-permission with multi-guard, panel-aware gating, and admin UX.

v13.0.1(1mo ago)08↑1025%MITPHP

Since Mar 20Pushed 1mo agoCompare

[ Source](https://github.com/AIArmada/filament-authz)[ Packagist](https://packagist.org/packages/aiarmada/filament-authz)[ Docs](https://github.com/aiarmada/commerce)[ RSS](/packages/aiarmada-filament-authz/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (5)Used By (0)

Filament Authz
==============

[](#filament-authz)

A comprehensive Filament v5 authorization package extending Spatie laravel-permission with wildcard permissions, multi-panel support, and automatic entity discovery.

Features
--------

[](#features)

- **Super Admin Bypass** — Configure a role that automatically bypasses all permission checks via `Gate::before`
- **Wildcard Permissions** — Support for patterns like `orders.*` to match `orders.view`, `orders.create`, etc.
- **Role &amp; Permission Resources** — Clean Filament UI for managing roles and permissions with tabbed interface
- **Automatic Discovery** — Discovers Resources, Pages, and Widgets to generate permissions automatically
- **Multi-Panel Support** — Configure different authorization settings per Filament panel
- **Policy Generation** — CLI command to scaffold Laravel Policies based on discovered permissions
- **Authz Scopes + Tenant Scoping** — Scope roles to any model (institutions, speakers, etc.) with central app support and optional commerce-support integration

Requirements
------------

[](#requirements)

- PHP 8.4+
- Laravel 12+
- Filament 5.0+
- Spatie laravel-permission 6.0+

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

[](#installation)

```
composer require aiarmada/filament-authz
```

Publish the configuration:

```
php artisan vendor:publish --tag=filament-authz-config
```

Publish and run Spatie Permission migrations:

```
php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider"
php artisan migrate
```

Setup
-----

[](#setup)

### Add HasRoles Trait

[](#add-hasroles-trait)

Add the `HasRoles` trait to your User model:

```
use Spatie\Permission\Traits\HasRoles;

class User extends Authenticatable
{
    use HasRoles;
}
```

### Register Plugin

[](#register-plugin)

Register the plugin in your Filament panel provider:

```
use AIArmada\FilamentAuthz\FilamentAuthzPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugins([
            FilamentAuthzPlugin::make(),
        ]);
}
```

Configuration
-------------

[](#configuration)

```
// config/filament-authz.php
return [
    // Authentication guards to support
    'guards' => ['web', 'api'],

    // Role that bypasses all permission checks
    'super_admin_role' => 'super_admin',

    // Enable wildcard permission patterns like 'orders.*'
    'wildcard_permissions' => true,

    // Scope roles and permissions to a tenant/scope (Spatie teams)
    'scoped_to_tenant' => true,

    // Allow managing roles across scopes in a central panel
    'central_app' => false,

    // Optional authz scopes (institutions, speakers, etc.)
    'authz_scopes' => [
        'enabled' => false,
        'auto_create' => true,
    ],

    'role_resource' => [
        'scope_options' => null,
    ],

    'user_resource' => [
        'form' => [
            'role_scope_mode' => 'all', // all, global_only, scoped_only
        ],
    ],

    // Permission key format
    'permissions' => [
        'separator' => '.',
        'case' => 'camel', // snake, kebab, camel, pascal, upper_snake, lower
    ],

    // Navigation settings
    'navigation' => [
        'group' => 'Authz',
        'sort' => 99,
    ],

    // Custom permissions beyond resources/pages/widgets
    'custom_permissions' => [
        // 'approve_posts' => 'Approve Posts',
    ],
];
```

Usage
-----

[](#usage)

### Permission Macros

[](#permission-macros)

```
use Filament\Actions\Action;

// Require a specific permission
Action::make('export')
    ->requiresPermission('order.export');

// Require a role
Action::make('admin-settings')
    ->requiresRole('Admin');

// Require any of multiple roles
Action::make('analytics')
    ->requiresRole(['Admin', 'Analyst']);

// Require any of multiple permissions
Action::make('reports')
    ->requiresAnyPermission(['report.view', 'report.export']);
```

### Wildcard Permissions

[](#wildcard-permissions)

```
// Grant 'orders.*' to a role
$role->givePermissionTo('orders.*');

// This now passes for any 'orders.X' check
$user->can('orders.view');   // true
$user->can('orders.create'); // true
$user->can('orders.delete'); // true
```

### Super Admin Bypass

[](#super-admin-bypass)

Users with the configured super admin role automatically bypass all permission checks:

```
// User with 'super_admin' role passes all gates
Gate::allows('any-permission'); // true
```

Authz Scopes (Optional)
-----------------------

[](#authz-scopes-optional)

Use Authz scopes to attach roles/permissions to any model (institutions, speakers, events, etc.).

```
// config/filament-authz.php
'authz_scopes' => [
    'enabled' => true,
    'auto_create' => true,
],

// config/permission.php
'teams' => true,
'team_foreign_key' => 'authz_scope_id',
```

```
use AIArmada\FilamentAuthz\Concerns\HasAuthzScope;
use AIArmada\FilamentAuthz\Facades\Authz;

class Workspace extends Model
{
    use HasAuthzScope;
}

Authz::userCanInScope($user, 'project.update', $workspace);
```

### Limiting Role Scope Options

[](#limiting-role-scope-options)

If your central panel should only expose a subset of scopes in the Role resource, provide an explicit options map.

```
use AIArmada\FilamentAuthz\FilamentAuthzPlugin;

FilamentAuthzPlugin::make()
    ->roleScopeOptionsUsing([
        'scope-id-1' => 'Team Members',
        'scope-id-2' => 'Support Team',
    ]);
```

Or through config:

```
'role_resource' => [
    'scope_options' => [
        'scope-id-1' => 'Team Members',
        'scope-id-2' => 'Support Team',
    ],
],
```

### Restricting User Role Editing By Scope

[](#restricting-user-role-editing-by-scope)

The User resource can expose:

- `all`
- `global_only`
- `scoped_only`

```
FilamentAuthzPlugin::make()
    ->userRoleScopeMode('global_only');
```

Or through config:

```
'user_resource' => [
    'form' => [
        'role_scope_mode' => 'global_only',
    ],
],
```

Commands
--------

[](#commands)

### Sync Permissions

[](#sync-permissions)

Sync roles and permissions from configuration:

```
php artisan authz:sync
```

### Doctor

[](#doctor)

Diagnose permission configuration issues:

```
php artisan authz:doctor
```

### Cache

[](#cache)

Manage permission cache:

```
php artisan authz:cache --flush
php artisan authz:cache --warm
```

Permission Naming Convention
----------------------------

[](#permission-naming-convention)

Use `{resource}.{ability}` format:

PermissionDescription`user.viewAny`View user list`user.view`View individual user`user.create`Create users`user.update`Update users`user.delete`Delete usersLicense
-------

[](#license)

MIT License. See [LICENSE](LICENSE) for details.

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance90

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

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 ~0 days

Total

4

Last Release

51d ago

Major Versions

v1.0.2 → v13.0.12026-03-20

### Community

Maintainers

![](https://www.gravatar.com/avatar/726da4efcb731bc0ebcdd0b7ce64759e1f8dd63f6f771eab335458f6a2f2d3af?d=identicon)[sairiz](/maintainers/sairiz)

### Embed Badge

![Health badge](/badges/aiarmada-filament-authz/health.svg)

```
[![Health](https://phpackages.com/badges/aiarmada-filament-authz/health.svg)](https://phpackages.com/packages/aiarmada-filament-authz)
```

###  Alternatives

[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[althinect/filament-spatie-roles-permissions

340954.7k9](/packages/althinect-filament-spatie-roles-permissions)[eduardoribeirodev/filament-leaflet

Um widget de mapa para FilamentPHP.

134.6k](/packages/eduardoribeirodev-filament-leaflet)

PHPackages © 2026

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