move into sonardesk

This commit is contained in:
Mark Gregory
2026-10-12 14:50:13 +01:00
parent 5f0d2ceb72
commit 38b4a7406f
879 changed files with 24021 additions and 1 deletions
@@ -0,0 +1,76 @@
<?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');
}
};