Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Filament Authentication Log Laravel Package

tapp/filament-authentication-log

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Install the Package

    composer require tapp/filament-authentication-log
    
  2. Publish Config & Migrations

    php artisan vendor:publish --provider="Tapp\FilamentAuthenticationLog\FilamentAuthenticationLogServiceProvider"
    php artisan migrate
    
  3. Configure Laravel Authentication Log Follow rappasoft/laravel-authentication-log to:

    • Add AuthenticationLoggable and Notifiable traits to your User model.
    • Publish its migrations if not already done.
  4. Register the Plugin Add to app/Providers/Filament/AdminPanelProvider.php:

    public function panel(Panel $panel): Panel
    {
        return $panel
            ->plugins([
                \Tapp\FilamentAuthenticationLog\FilamentAuthenticationLogPlugin::make(),
            ]);
    }
    
  5. First Use Case Access the Authentication Logs plugin via the Filament admin panel sidebar. View, filter, and export login attempts (successful/failed) for all users.


Implementation Patterns

Core Workflows

  1. Monitoring Logins

    • Use the Authentication Logs resource to audit user activity (IP, timestamp, status).
    • Filter logs by user_id, status, or created_at via Filament’s built-in search/filter UI.
  2. User-Specific Logs

    • Attach the Authentication Log Relation Manager to your User resource:
      use Tapp\FilamentAuthenticationLog\Resources\AuthenticationLogRelationManager;
      
      public static function getRelations(): array
      {
          return [
              AuthenticationLogRelationManager::make(),
          ];
      }
      
    • Access logs directly from the user profile page.
  3. Exporting Data

    • Export logs to CSV/Excel via Filament’s bulk actions:
      ->actions([
          Tables\Actions\ExportAction::make(),
      ])
      
  4. Customizing Logs

    • Extend the AuthenticationLog model or override the Filament resource:
      use Tapp\FilamentAuthenticationLog\Resources\AuthenticationLogResource;
      
      class CustomAuthenticationLogResource extends AuthenticationLogResource
      {
          public static function form(Form $form): Form
          {
              return parent::form($form)
                  ->columns(2)
                  ->schema([
                      // Add custom fields (e.g., from laravel-authentication-log)
                  ]);
          }
      }
      
  5. Notifying Admins

    • Leverage laravel-authentication-log's Notifiable trait to trigger alerts (e.g., failed logins):
      // In User model
      public function sendFailedLoginNotification()
      {
          $this->notify(new FailedLoginNotification());
      }
      

Gotchas and Tips

Pitfalls

  1. Missing Dependencies

    • Forgetting to install rappasoft/laravel-authentication-log will break the plugin. Verify with:
      composer require rappasoft/laravel-authentication-log
      
  2. Migration Conflicts

    • If laravel-authentication-log migrations were run separately, republish its migrations to avoid table conflicts:
      php artisan vendor:publish --tag="authentication-log-migrations"
      
  3. Permission Issues

    • Ensure the Filament admin user has access to the plugin. Add to AdminPanelProvider:
      ->middleware([
          'auth',
          'verified',
          'can:access-authentication-logs', // Custom gate
      ])
      
  4. Relation Manager Not Showing

    • If logs don’t appear in the User resource, verify:
      • The AuthenticationLog model’s user() relation is correctly defined.
      • The relation manager is properly registered in getRelations().
  5. Timezone Mismatches

    • Log timestamps may appear incorrect if authentication_log table’s created_at uses a different timezone. Set in config/authentication-log.php:
      'timezone' => 'UTC',
      

Debugging Tips

  • Check Logs: Use php artisan authentication-log:list to verify raw log data.
  • Clear Cache: After publishing config/migrations, run:
    php artisan optimize:clear
    php artisan cache:clear
    
  • Test with Tinker:
    php artisan tinker
    >> \App\Models\User::first()->authenticationLogs()->count();
    

Extension Points

  1. Custom Columns Override the resource’s table columns:

    public static function table(Table $table): Table
    {
        return parent::table($table)
            ->columns([
                Tables\Columns\TextColumn::make('ip_address')
                    ->label('IP Address'),
                // Add more...
            ]);
    }
    
  2. Webhook Triggers Hook into authentication.logged or authentication.failed events (from laravel-authentication-log) to sync with external systems:

    // In EventServiceProvider
    protected $listen = [
        'authentication.logged' => [
            \App\Listeners\LogLoginToExternalSystem::class,
        ],
    ];
    
  3. Bulk Actions Add custom bulk actions (e.g., "Block User After X Failed Attempts"):

    ->actions([
        Tables\Actions\BulkAction::make('blockUser')
            ->action(function (Collection $records) {
                // Logic to block users
            }),
    ])
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
besmartand-pro/php-quality-config
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity