Beautiful Open-Source Form Builder
Extend exported file link expiration (#1103)
Julien Nahum41115864c2f1
diff --git a/api/app/Service/Forms/FormSubmissionFormatter.php b/api/app/Service/Forms/FormSubmissionFormatter.phpindex 999c1271c..8809e609e 100644--- a/api/app/Service/Forms/FormSubmissionFormatter.php+++ b/api/app/Service/Forms/FormSubmissionFormatter.php@@ -10,6 +10,8 @@ use Illuminate\Support\Facades\URL;class FormSubmissionFormatter{+ public const SIGNED_FILE_URL_EXPIRATION_MINUTES = 60 * 24;+/*** If true, creates html <a> links for emails and urls*@@ -350,7 +352,7 @@ class FormSubmissionFormatterreturn $this->useSignedUrlForFiles ? URL::temporarySignedRoute('open.forms.submissions.file',- now()->addMinutes(config('vapor.signed_storage_url_expires_after', 5)),+ now()->addMinutes(self::SIGNED_FILE_URL_EXPIRATION_MINUTES),[$formId, $encodedFilename]) : route('open.forms.submissions.file', [$formId, $encodedFilename]);} catch (\Exception $e) {diff --git a/api/tests/Feature/Forms/FormSubmissionExportTest.php b/api/tests/Feature/Forms/FormSubmissionExportTest.phpindex d3b90c540..1138ea00b 100644--- a/api/tests/Feature/Forms/FormSubmissionExportTest.php+++ b/api/tests/Feature/Forms/FormSubmissionExportTest.php@@ -2,6 +2,7 @@use App\Models\User;use App\Models\Forms\FormSubmission;+use App\Service\Forms\FormSubmissionFormatter;use App\Service\Storage\FileUploadPathService;use Illuminate\Support\Facades\Storage;@@ -323,7 +324,7 @@ it('does not include status column when partial submissions are disabled', functexpect(str_contains($content, 'status'))->toBeFalse();});-it('exports file urls with expiration and a valid signature', function () {+it('exports file urls with a durable expiration and a valid signature', function () {$user = $this->actingAsProUser();$workspace = $this->createUserWorkspace($user);$form = $this->createForm($user, $workspace, [@@ -369,6 +370,13 @@ it('exports file urls with expiration and a valid signature', function () {parse_str(parse_url($exportedFileUrl, PHP_URL_QUERY), $queryParameters);expect($queryParameters)->toHaveKeys(['expires', 'signature']);+ expect((int) $queryParameters['expires'])->toBeGreaterThan(now()->addMinutes(FormSubmissionFormatter::SIGNED_FILE_URL_EXPIRATION_MINUTES - 1)->timestamp);$this->get($exportedFileUrl)->assertOk();++ $this->travel(6)->minutes();++ $this->get($exportedFileUrl)->assertOk();++ $this->travelBack();});