dutchcodingcompany/filament-developer-logins
composer require dutchcodingcompany/filament-developer-logins
php artisan vendor:publish --provider="DutchCodingCompany\FilamentDeveloperLogins\FilamentDeveloperLoginsServiceProvider"
PanelProvider (e.g., app/Providers/Filament/AdminPanelProvider.php), register the plugin:
public function panel(Panel $panel): Panel
{
return $panel
->plugin(FilamentDeveloperLoginsPlugin::make());
}
php artisan filament:login.demo@user.com).Define Developer Users:
Configure users in config/filament-developer-logins.php:
'users' => [
'admin@example.com' => [
'password' => 'password',
'role' => 'admin',
],
'editor@example.com' => [
'password' => 'editor123',
'role' => 'editor',
],
],
auth_identifier).'users' => [
'query' => User::query()
->where('is_developer', true)
->select('email', 'password', 'role'),
],
Customize the UI:
'groups' => [
'Admins' => ['admin@example.com', 'superadmin@example.com'],
'Editors' => ['editor@example.com'],
],
'user_button' => FilamentDeveloperLoginsUserButton::make()
->icon('heroicon-o-user')
->color('success'),
Integration with Filament Features:
->visible(app()->environment('local'))
FilamentDeveloperLogins::listen('logged-in', function (User $user) {
event(new UserLoggedIn($user));
});
Multi-Panel Support: Register the plugin in each panel where needed:
->plugin(FilamentDeveloperLoginsPlugin::make()->forPanel('tenant'))
Dynamic User Providers:
Extend the UserProvider interface to fetch users from external APIs or caches:
FilamentDeveloperLogins::extend('custom_provider', function () {
return new CustomUserProvider();
});
Rate Limiting: Protect against brute-force attempts by adding middleware:
->middleware([
\Filament\Panel\Middleware\Authenticate::class,
\Illuminate\Cache\Middleware\LimitRequests::class,
])
Localization: Translate button labels and messages:
'labels' => [
'login_as' => 'Login as User',
'back_to_login' => 'Back to Login',
],
Password Hashing:
php artisan filament:login to generate hashed passwords, then store them in the config:
'users' => [
'admin@example.com' => [
'password' => '$2y...', // Hashed password
],
],
Hash::make() in a migration or seeder.User Not Found:
'debug' => true,
auth_identifier (e.g., email) matches your User model’s fillable fields.CSRF Token Mismatch:
->middleware([
EnsureFrontendAssetsArePublished::class,
VerifyCsrfToken::class, // Must come before FilamentDeveloperLogins
])
Caching Headaches:
users config aren’t reflected immediately.php artisan config:clear
config_cache only in production.Log User Logins: Add a listener to track activity:
FilamentDeveloperLogins::listen('logged-in', function (User $user) {
\Log::info("Developer login as {$user->email}", ['ip' => request()->ip()]);
});
Inspect Requests: Dump the request payload before login:
FilamentDeveloperLogins::listen('logging-in', function (array $data) {
\Log::debug('Login attempt', $data);
});
Test Locally:
Use php artisan filament:login to verify users work before exposing them via the plugin.
Custom User Buttons: Override the default button template:
FilamentDeveloperLogins::macro('userButton', function () {
return FilamentDeveloperLoginsUserButton::make()
->icon('heroicon-o-shield-check')
->extraAttributes(['class' => 'bg-blue-500']);
});
Pre-Login Actions: Run logic before a user logs in (e.g., set a session variable):
FilamentDeveloperLogins::listen('before-login', function (User $user) {
session()->put('developer_login', true);
});
Post-Login Redirects: Override the default redirect behavior:
FilamentDeveloperLogins::macro('redirect', function (User $user) {
return redirect()->route('filament.admin.pages.dashboard');
});
Environment-Specific Users: Load different users per environment:
'users' => app()->environment('local')
? require __DIR__ . '/developer-users-local.php'
: require __DIR__ . '/developer-users-staging.php',
Combine with Filament Actions: Use the plugin to trigger actions like "Impersonate User" in a resource table:
UseFilamentDeveloperLogins::make()
->label('Impersonate')
->action(function (User $record) {
FilamentDeveloperLogins::loginAs($record);
}),
Git Ignore: Exclude the config file if it contains sensitive data:
config/filament-developer-logins.php
CI/CD Safety:
Never commit plain-text passwords. Use environment variables or Laravel’s .env:
FILAMENT_DEVELOPER_LOGINS_PASSWORD_ADMIN=hashed_password_here
How can I help you explore Laravel packages today?