juliomotol/filament-password-confirmation

Prompt users to re-enter their password before performing sensitive actions.

v1.1.0 2024-05-05 13:25 UTC

This package is auto-updated.

Last update: 2024-05-05 13:33:56 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Simplifies adding a secure password confirmation step to your admin panels.

  • Prompts users to re-enter their password before performing sensitive actions.
  • Increases security by preventing accidental or unauthorized actions due to long session times.
  • Easy to integrate and highly configurable.

Installation

You can install the package via composer:

composer require juliomotol/filament-password-confirmation

Then add the plugin to your panel.

JulioMotol\FilamentPasswordConfirmation\FilamentPasswordConfirmationPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
       ->plugin(RenewPasswordPlugin::make());
}

You can configure the route name, uri, middleware and password timeout duration.

RenewPasswordPlugin::make()
    ->routeName('confirm')
    ->routeUri('auth/confirm')
    ->routeMiddleware(FooMiddleware::class) // Accepts string|array
    ->passwordTimeout(10800) // Accepts int|null that represents the amount of seconds

Optionally, you can publish the translations and views using.

php artisan vendor:publish --tag="filament-password-confirmation-translations"
php artisan vendor:publish --tag="filament-password-confirmation-views"

Usage

Simply use RequiresPasswordConfirmation in your pages/resources.

use JulioMotol\FilamentPasswordConfirmation\RequiresPasswordConfirmation;

class AdminResource extends Resource
{
    use RequiresPasswordConfirmation;
    ...
}

You can configure the password confirmation timeout within your page/resource.

use JulioMotol\FilamentPasswordConfirmation\RequiresPasswordConfirmation;

class AdminResource extends Resource
{
    use RequiresPasswordConfirmation;

    protected static ?int $passwordTimeout = 360; // the amount of seconds
    ...
}

NOTE: The password timeout duration is determined in the following order until it encounters a non-null value.

  1. $passwordTimeout property in the page/resource
  2. passwordTimeout() configured in the plugin during registry
  3. auth.password_timeout config assigned in config/auth.php

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.