mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-01-19 17:12:46 +08:00
ZIP Exports: Changed the instance id mechanism
Some checks failed
analyse-php / build (push) Has been cancelled
lint-php / build (push) Has been cancelled
test-migrations / build (8.1) (push) Has been cancelled
test-migrations / build (8.2) (push) Has been cancelled
test-migrations / build (8.3) (push) Has been cancelled
test-php / build (8.1) (push) Has been cancelled
test-php / build (8.2) (push) Has been cancelled
test-php / build (8.3) (push) Has been cancelled
Some checks failed
analyse-php / build (push) Has been cancelled
lint-php / build (push) Has been cancelled
test-migrations / build (8.1) (push) Has been cancelled
test-migrations / build (8.2) (push) Has been cancelled
test-migrations / build (8.3) (push) Has been cancelled
test-php / build (8.1) (push) Has been cancelled
test-php / build (8.2) (push) Has been cancelled
test-php / build (8.3) (push) Has been cancelled
Adds an instance id via app settings.
This commit is contained in:
parent
edb684c72c
commit
bdca9fc1ce
|
@ -69,8 +69,8 @@ class ZipExportBuilder
|
|||
|
||||
$this->data['exported_at'] = date(DATE_ATOM);
|
||||
$this->data['instance'] = [
|
||||
'version' => trim(file_get_contents(base_path('version'))),
|
||||
'id_ciphertext' => encrypt('bookstack'),
|
||||
'id' => setting('instance-id', ''),
|
||||
'version' => trim(file_get_contents(base_path('version'))),
|
||||
];
|
||||
|
||||
$zipFile = tempnam(sys_get_temp_dir(), 'bszip-');
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
DB::table('settings')->insert([
|
||||
'setting_key' => 'instance-id',
|
||||
'value' => Str::uuid(),
|
||||
'created_at' => Carbon::now(),
|
||||
'updated_at' => Carbon::now(),
|
||||
'type' => 'string',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
DB::table('settings')->where('setting_key', '=', 'instance-id')->delete();
|
||||
}
|
||||
};
|
|
@ -93,12 +93,10 @@ The below details the objects & their properties used in Application Data.
|
|||
|
||||
#### Instance
|
||||
|
||||
These details are mainly informational regarding the exporting BookStack instance from where an export was created from.
|
||||
These details are informational regarding the exporting BookStack instance from where an export was created from.
|
||||
|
||||
- `id` - String, required, unique identifier for the BookStack instance.
|
||||
- `version` - String, required, BookStack version of the export source instance.
|
||||
- `id_ciphertext` - String, required, identifier for the BookStack instance.
|
||||
|
||||
The `id_ciphertext` is the ciphertext of encrypting the text `bookstack`. This is used as a simple & rough way for a BookStack instance to be able to identify if they were the source (by attempting to decrypt the ciphertext).
|
||||
|
||||
#### Book
|
||||
|
||||
|
|
|
@ -54,8 +54,10 @@ class ZipExportTest extends TestCase
|
|||
$version = trim(file_get_contents(base_path('version')));
|
||||
$this->assertEquals($version, $zip->data['instance']['version']);
|
||||
|
||||
$instanceId = decrypt($zip->data['instance']['id_ciphertext']);
|
||||
$this->assertEquals('bookstack', $instanceId);
|
||||
$zipInstanceId = $zip->data['instance']['id'];
|
||||
$instanceId = setting('instance-id');
|
||||
$this->assertNotEmpty($instanceId);
|
||||
$this->assertEquals($instanceId, $zipInstanceId);
|
||||
}
|
||||
|
||||
public function test_page_export()
|
||||
|
|
Loading…
Reference in New Issue
Block a user