Central Security Centre

* Security policy management
* Minimum password-length policy
* Mixed-case, number, and symbol requirements
* Password expiry and history settings
* MFA requirement policy
* Failed-login and lockout settings
* Session idle-time policy
* Single-session policy
* Automatic successful-login recording
* Automatic failed-login recording
* Automatic logout recording
* Authentication history
* IP allow and deny rules
* IPv4 CIDR support
* Administration and login rule scopes
* Trusted-device storage and revocation
* Security middleware registration
* Administration navigation
* Security permissions
* Module registration and tests
This commit is contained in:
Mark Gregory
2026-07-24 12:30:40 +01:00
parent 86f2bc75aa
commit 7fb71c4d24
21 changed files with 270 additions and 3 deletions
@@ -0,0 +1,45 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void
{
Schema::create('security_policies', function (Blueprint $table) {
$table->id(); $table->string('name')->default('Default security policy');
$table->unsignedSmallInteger('minimum_password_length')->default(12);
$table->boolean('require_mixed_case')->default(true); $table->boolean('require_numbers')->default(true);
$table->boolean('require_symbols')->default(true); $table->boolean('require_mfa')->default(false);
$table->unsignedInteger('password_expiry_days')->nullable(); $table->unsignedSmallInteger('password_history')->default(5);
$table->unsignedSmallInteger('max_failed_logins')->default(10); $table->unsignedSmallInteger('lockout_minutes')->default(15);
$table->unsignedSmallInteger('session_idle_minutes')->default(120); $table->boolean('single_session')->default(false);
$table->boolean('is_active')->default(true); $table->timestamps();
});
Schema::create('security_login_events', function (Blueprint $table) {
$table->id(); $table->foreignId('user_id')->nullable()->constrained()->nullOnDelete();
$table->string('email')->nullable()->index(); $table->string('event', 30)->index();
$table->string('ip_address', 45)->nullable()->index(); $table->text('user_agent')->nullable();
$table->string('session_id')->nullable()->index(); $table->string('reason')->nullable();
$table->json('metadata')->nullable(); $table->timestamp('occurred_at')->useCurrent(); $table->timestamps();
});
Schema::create('security_devices', function (Blueprint $table) {
$table->id(); $table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->string('name'); $table->string('fingerprint', 64)->index(); $table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable(); $table->timestamp('trusted_until')->nullable();
$table->timestamp('last_seen_at')->nullable(); $table->timestamp('revoked_at')->nullable(); $table->timestamps();
$table->unique(['user_id','fingerprint']);
});
Schema::create('security_ip_rules', function (Blueprint $table) {
$table->id(); $table->string('name'); $table->string('type', 10)->default('deny');
$table->string('address', 64); $table->text('description')->nullable();
$table->boolean('applies_to_admin')->default(true); $table->boolean('applies_to_login')->default(true);
$table->boolean('is_active')->default(true); $table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete();
$table->timestamps(); $table->index(['type','is_active']);
});
}
public function down(): void
{
Schema::dropIfExists('security_ip_rules'); Schema::dropIfExists('security_devices');
Schema::dropIfExists('security_login_events'); Schema::dropIfExists('security_policies');
}
};