PHPackages                             phpsa/filament-authentication - 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. [CLI &amp; Console](/categories/cli)
4. /
5. phpsa/filament-authentication

ActiveLibrary[CLI &amp; Console](/categories/cli)

phpsa/filament-authentication
=============================

User &amp; Role (via Spatie Roles/Permissions) Manager Resource For Filament Admin

v5.1.1(1y ago)12663.6k↑29.4%22[2 issues](https://github.com/phpsa/filament-authentication/issues)MITPHPPHP ^8.1

Since Apr 20Pushed 3mo ago6 watchersCompare

[ Source](https://github.com/phpsa/filament-authentication)[ Packagist](https://packagist.org/packages/phpsa/filament-authentication)[ Docs](https://cgs4k.nz)[ GitHub Sponsors](https://github.com/phpsa)[ RSS](/packages/phpsa-filament-authentication/feed)WikiDiscussions 5.x Synced 1mo ago

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

[![Latest Version on Packagist](https://camo.githubusercontent.com/80f91d18ae6124010799f9e2a44f01a19c6b30a5f5c3461815a93b645b037510/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f70687073612f66696c616d656e742d61757468656e7469636174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/phpsa/filament-authentication)[![Semantic Release](https://github.com/phpsa/filament-authentication/actions/workflows/release.yml/badge.svg)](https://github.com/phpsa/filament-authentication/actions/workflows/release.yml)[![Total Downloads](https://camo.githubusercontent.com/4ac7c76544e1f0e05f8f02b4cb1d05eb5e2bb2b1444ac83617d48211ee17fe4f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f70687073612f66696c616d656e742d61757468656e7469636174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/phpsa/filament-authentication)

Filament User Authentication
============================

[](#filament-user-authentication)

User Resource For Filament Admin along with Roles &amp; Permissions using Spatie

Package Installation
--------------------

[](#package-installation)

You can install the package via composer:

```
composer require phpsa/filament-authentication
```

and run the install command

```
php artisan filament-authentication:install
```

this will publish the config file and migrations

optionally publish views / translations

```
artisan vendor:publish --tag=filament-authentication-views
artisan vendor:publish --tag=filament-authentication-translations
```

### Spatie Roles &amp; Permissions

[](#spatie-roles--permissions)

If you have not yet configured this package it is automatically added by this installer, run the following steps:

1. You should publish the migration and the config/permission.php config file with:

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

2. Add the `Spatie\Permission\Traits\HasRoles` trait to your Users model
3. Add Roles &amp; Permissions as required

For more see:

Setup &amp; Config
------------------

[](#setup--config)

in your Filament panel file you need to add the following to the Plugins section

add the resources

```
 public function panel(Panel $panel): Panel
    {
        return $panel
            ...
            ->plugins([
                \Phpsa\FilamentAuthentication\FilamentAuthentication::make(),
            ])
            ...
```

You can configure this via either the config file or the plugin.

Features
========

[](#features)

1. Widgets
----------

[](#1-widgets)

`LatestUsersWidget` can be added to your dashboard by adding it to your panel widgets area..

```
 LatestUsersWidget::class

```

Note that it is also attached to the UserPolicy::viewAny policy value if the policy exists

2. Laravel Impersonate
----------------------

[](#2-laravel-impersonate)

If you have not configured this package it is automatically added by this install, run the following steps:

1. Add the trait `Lab404\Impersonate\Models\Impersonate` to your User model.
2. edit the config file and set impersonate-&gt;enabled to true

### Defining impersonation authorization

[](#defining-impersonation-authorization)

By default all users can **impersonate** an user. You need to add the method `canImpersonate()` to your user model:

```
    /**
     * @return bool
     */
    public function canImpersonate()
    {
        // For example
        return $this->is_admin == 1;
    }
```

By default all users can **be impersonated**. You need to add the method `canBeImpersonated()` to your user model to extend this behavior:

```
    /**
     * @return bool
     */
    public function canBeImpersonated()
    {
        // For example
        return $this->can_be_impersonated == 1;
    }
```

**Protect From Impersonation**

You can use the middleware `impersonate.protect` to protect your routes against user impersonation. This middleware can be useful when you want to protect specific pages like users subscriptions, users credit cards, ...

```
Router::get('/my-credit-card', function() {
    echo "Can't be accessed by an impersonator";
})->middleware('impersonate.protect');
```

**Events**There are two events available that can be used to improve your workflow:

- `TakeImpersonation` is fired when an impersonation is taken.
- `LeaveImpersonation` is fired when an impersonation is leaved.

Each events returns two properties `$event->impersonator` and `$event->impersonated` containing User model instance.

3. Password Renewal
-------------------

[](#3-password-renewal)

Introduced in V4.2.0 - this allows you to enforce a user to change their password every X days.

Enable this &amp; configure this as Follows:

1. add the `Phpsa\FilamentAuthentication\Traits\CanRenewPassword` trait to your user model
2. configure the options for pruning and renewal day period in the config file
3. if not published, publish migration `artisan vendor:publish --tag filament-authentication-migrations`

this will force a user to update their password, note -- all existing users will initially be foreced to, this can be ignored by running the following command:

From V5.0.0 - there is a new validation rule that can be added to validate that a password has not been used before. `Phpsa\FilamentAuthentication\Rules\PreventPasswordReuseRule` - this will use the value from config `filament-authentication.password_renew.prevent_password_reuse` 0 to disable, any number of previous to block out fro re-use.

\-- If using socialite / Filament-socialite etc, you will need to override the `public function needsRenewal(): bool` method in the trait, EG:

```
 use CanRenewPassword {
        CanRenewPassword::needsRenewal as traitNeedsRenewal;
    }

    public function needsRenewal(): bool
    {
        if ($this->password === null && SocialiteUser::where('user_id', $this->id)->exists()) {
            return false;
        }
        return $this->traitNeedsRenewal();
    }
```

Authentication Log
------------------

[](#authentication-log)

Introduced in V4.2.0 - this allows you to log each user login attempt.

Enable this &amp; configure this as follows:

1. add the `Phpsa\FilamentAuthentication\Traits\LogsAuthentication` trait to your user model
2. configure the options for prune in the authentication\_log section of the config
3. optionally enable the resource in navigation section of the config file.
4. if not published, publish migration `artisan vendor:publish --tag filament-authentication-migrations`

this will now log login and logouts on the system.

Security
--------

[](#security)

Roles &amp; Permissions can be secured using Laravel Policies, create your policies and register then in the AuthServiceProvider

```
 protected $policies = [
        Role::class       => RolePolicy::class,
        Permission::class => PermissionPolicy::class,
        CustomPage::class => CustomPagePolicy::class,
        SettingsPage::class => SettingsPagePolicy::class
        // 'App\Models\Model' => 'App\Policies\ModelPolicy',
    ];
```

We have a Custom Page Trait: `Phpsa\FilamentAuthentication\Traits\PagePolicyTrait` and a Spatie Settings Page Trait `Phpsa\FilamentAuthentication\Traits\SettingsPage\PolicyTrait` that you can add to your pages / settings pages. By defining a model and mapping it with a `viewAny($user)` method you can define per policies whether or not to show the page in navigation.

Events
------

[](#events)

`Phpsa\FilamentAuthentication\Events\UserCreated` is triggered when a user is created via the Resource

`Phpsa\FilamentAuthentication\Events\UserUpdated` is triggered when a user is updated via the Resource

Future Plans
------------

[](#future-plans)

- MFA Authentication
- Socialite Authentication
- Biometrics Athentication

Changelog
---------

[](#changelog)

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

Credits
-------

[](#credits)

- [Phpsa](https://github.com/phpsa)

License
-------

[](#license)

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

###  Health Score

55

—

FairBetter than 98% of packages

Maintenance64

Regular maintenance activity

Popularity47

Moderate usage in the ecosystem

Community24

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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

Recently: every ~40 days

Total

37

Last Release

405d ago

Major Versions

2.x-dev → v3.0.02023-11-30

v3.2.1 → v4.0.02024-02-18

v4.2.1 → v5.0.0-alpha.12024-06-01

v4.3.0-beta.2 → v5.0.0-beta.12024-08-04

4.x-dev → v5.1.02025-03-01

PHP version history (2 changes)v1.0.0PHP ^8.0

v5.0.0-alpha.1PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/bbe4c97ef26aca9d6792775ea44a4c83215881b158f2d3894279c7b73bedda3c?d=identicon)[phpsa](/maintainers/phpsa)

---

Top Contributors

[![phpsa](https://avatars.githubusercontent.com/u/952595?v=4)](https://github.com/phpsa "phpsa (37 commits)")[![craigAtCD](https://avatars.githubusercontent.com/u/152445143?v=4)](https://github.com/craigAtCD "craigAtCD (18 commits)")[![semantic-release-bot](https://avatars.githubusercontent.com/u/32174276?v=4)](https://github.com/semantic-release-bot "semantic-release-bot (17 commits)")[![FalconNL93](https://avatars.githubusercontent.com/u/78677816?v=4)](https://github.com/FalconNL93 "FalconNL93 (3 commits)")[![shibomb](https://avatars.githubusercontent.com/u/958471?v=4)](https://github.com/shibomb "shibomb (2 commits)")[![nguyentranchung](https://avatars.githubusercontent.com/u/9611224?v=4)](https://github.com/nguyentranchung "nguyentranchung (2 commits)")[![RickAtCD](https://avatars.githubusercontent.com/u/108494667?v=4)](https://github.com/RickAtCD "RickAtCD (1 commits)")[![tiagof](https://avatars.githubusercontent.com/u/1729910?v=4)](https://github.com/tiagof "tiagof (1 commits)")[![chengkangzai](https://avatars.githubusercontent.com/u/43839286?v=4)](https://github.com/chengkangzai "chengkangzai (1 commits)")[![z4nder](https://avatars.githubusercontent.com/u/39275291?v=4)](https://github.com/z4nder "z4nder (1 commits)")[![danie1net0](https://avatars.githubusercontent.com/u/19168799?v=4)](https://github.com/danie1net0 "danie1net0 (1 commits)")[![datlechin](https://avatars.githubusercontent.com/u/56961917?v=4)](https://github.com/datlechin "datlechin (1 commits)")[![dpetrovaliev](https://avatars.githubusercontent.com/u/53557596?v=4)](https://github.com/dpetrovaliev "dpetrovaliev (1 commits)")[![eelco2k](https://avatars.githubusercontent.com/u/878103?v=4)](https://github.com/eelco2k "eelco2k (1 commits)")[![moskoweb](https://avatars.githubusercontent.com/u/6052272?v=4)](https://github.com/moskoweb "moskoweb (1 commits)")

---

Tags

laravelpermissionsclilaraveluiuserresourcefilament

###  Code Quality

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/phpsa-filament-authentication/health.svg)

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

###  Alternatives

[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[phpsa/filament-password-reveal

Password Input with option to show

51143.4k2](/packages/phpsa-filament-password-reveal)[phpsa/filament-dadjokes

With DadJokes every time you load your control panel you'll be greeted by an epic dad joke on the dashboard.

1714.1k](/packages/phpsa-filament-dadjokes)[andreia/filament-ui-switcher

Add a modal with options to switch between different UI layouts and styles (colors, fonts, font sizes).

233.8k](/packages/andreia-filament-ui-switcher)[a2insights/filament-saas

Filament Saas for A2Insights

161.1k](/packages/a2insights-filament-saas)

PHPackages © 2026

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