Add SealShare file sharing application with encryption, branding, auth, Docker, and Octane support
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
4790be8142
commit
e37b322dde
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Share;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends Factory<Share>
|
||||
*/
|
||||
class ShareFactory extends Factory
|
||||
{
|
||||
protected $model = Share::class;
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'token' => Str::random(16),
|
||||
'password' => null,
|
||||
'encryption_key' => null,
|
||||
'encryption_salt' => bin2hex(random_bytes(32)),
|
||||
'expires_at' => null,
|
||||
'max_downloads' => null,
|
||||
'download_count' => 0,
|
||||
'total_size' => 0,
|
||||
];
|
||||
}
|
||||
|
||||
public function withPassword(string $password = 'secret'): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'password' => bcrypt($password),
|
||||
]);
|
||||
}
|
||||
|
||||
public function expired(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'expires_at' => now()->subHour(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function withMaxDownloads(int $max = 5): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'max_downloads' => $max,
|
||||
]);
|
||||
}
|
||||
|
||||
public function expiresInHours(int $hours = 24): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'expires_at' => now()->addHours($hours),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Share;
|
||||
use App\Models\ShareFile;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<ShareFile>
|
||||
*/
|
||||
class ShareFileFactory extends Factory
|
||||
{
|
||||
protected $model = ShareFile::class;
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'share_id' => Share::factory(),
|
||||
'original_name' => fake()->word().'.txt',
|
||||
'relative_path' => null,
|
||||
'stored_path' => 'shares/'.fake()->uuid().'.enc',
|
||||
'file_size' => fake()->numberBetween(1024, 10485760),
|
||||
'mime_type' => 'text/plain',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -45,6 +45,16 @@ class UserFactory extends Factory
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the user is an admin.
|
||||
*/
|
||||
public function admin(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'is_admin' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model has two-factor authentication configured.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->boolean('is_admin')->default(false)->after('remember_token');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn('is_admin');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('shares', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('token', 16)->unique();
|
||||
$table->string('password')->nullable();
|
||||
$table->text('encryption_key')->nullable();
|
||||
$table->string('encryption_salt')->nullable();
|
||||
$table->timestamp('expires_at')->nullable();
|
||||
$table->unsignedInteger('max_downloads')->nullable();
|
||||
$table->unsignedInteger('download_count')->default(0);
|
||||
$table->unsignedBigInteger('total_size')->default(0);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('shares');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('share_files', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('share_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('original_name');
|
||||
$table->string('relative_path')->nullable();
|
||||
$table->string('stored_path');
|
||||
$table->unsignedBigInteger('file_size')->default(0);
|
||||
$table->string('mime_type')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('share_files');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('settings', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('key')->unique();
|
||||
$table->text('value')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('settings');
|
||||
}
|
||||
};
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
@@ -19,5 +20,8 @@ class DatabaseSeeder extends Seeder
|
||||
'name' => 'Test User',
|
||||
'email' => 'test@example.com',
|
||||
]);
|
||||
|
||||
Setting::set('site_title', 'SealShare');
|
||||
Setting::set('site_description', 'Simple, secure file sharing');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user