From 5792c4f32dfc195e7f5bb12e564e06b8f096d417 Mon Sep 17 00:00:00 2001 From: Adamo Date: Fri, 6 Dec 2024 09:17:19 +0100 Subject: [PATCH 1/4] [DURACOM-312] updated UploaderOptions to include impersonatingID. (cherry picked from commit 2c79be1456c753665e27b58563e56accc87b0383) (cherry picked from commit 4b0ab8161f0412ed322c265767462e0ef262ce9e) --- src/app/shared/upload/uploader/uploader-options.model.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/app/shared/upload/uploader/uploader-options.model.ts b/src/app/shared/upload/uploader/uploader-options.model.ts index 559fb0485b..e21628d06e 100644 --- a/src/app/shared/upload/uploader/uploader-options.model.ts +++ b/src/app/shared/upload/uploader/uploader-options.model.ts @@ -22,6 +22,11 @@ export class UploaderOptions { */ maxFileNumber: number; + /** + * Impersonating user uuid + */ + impersonatingID: string; + /** * The request method to use for the file upload request */ From 0439d073746253c0ebc349c901ea38bf921618ca Mon Sep 17 00:00:00 2001 From: Adamo Date: Fri, 6 Dec 2024 09:18:47 +0100 Subject: [PATCH 2/4] [DURACOM-312] set the newly created impersonatingID filed in UploaderOptions. (cherry picked from commit c70fe184208805be8657d4373f50f193e2c6e85f) (cherry picked from commit 70c6af363042676d95e473e3a09a4c7d6d3e5490) --- src/app/submission/form/submission-form.component.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app/submission/form/submission-form.component.ts b/src/app/submission/form/submission-form.component.ts index 74c262befc..67e2e9691b 100644 --- a/src/app/submission/form/submission-form.component.ts +++ b/src/app/submission/form/submission-form.component.ts @@ -209,6 +209,7 @@ export class SubmissionFormComponent implements OnChanges, OnDestroy { distinctUntilChanged()) .subscribe((endpointURL) => { this.uploadFilesOptions.authToken = this.authService.buildAuthHeader(); + this.uploadFilesOptions.impersonatingID = this.authService.getImpersonateID(); this.uploadFilesOptions.url = endpointURL.concat(`/${this.submissionId}`); this.definitionId = this.submissionDefinition.name; this.submissionService.dispatchInit( From 0c564cb9c2d7ba3dfbf331a5c766ec1135fce500 Mon Sep 17 00:00:00 2001 From: Adamo Date: Fri, 6 Dec 2024 09:20:14 +0100 Subject: [PATCH 3/4] [DURACOM-312] set the X-On-Behalf-Of header with impersonatingID in FileUploader. (cherry picked from commit 727bcdc2cb23ae7fcff1d9ddfa794f872f1d1b8c) (cherry picked from commit 0574c8ed9856b28e8a000624f8aad42ca4ec9ecb) --- .../shared/upload/uploader/uploader.component.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/app/shared/upload/uploader/uploader.component.ts b/src/app/shared/upload/uploader/uploader.component.ts index fbafe811eb..5bb8a44a77 100644 --- a/src/app/shared/upload/uploader/uploader.component.ts +++ b/src/app/shared/upload/uploader/uploader.component.ts @@ -47,6 +47,11 @@ import { UploaderProperties } from './uploader-properties.model'; }) export class UploaderComponent implements OnInit, AfterViewInit { + /** + * Header key to impersonate a user + */ + private readonly ON_BEHALF_HEADER = 'X-On-Behalf-Of'; + /** * The message to show when drag files on the drop zone */ @@ -162,7 +167,13 @@ export class UploaderComponent implements OnInit, AfterViewInit { item.url = this.uploader.options.url; } // Ensure the current XSRF token is included in every upload request (token may change between items uploaded) - this.uploader.options.headers = [{ name: XSRF_REQUEST_HEADER, value: this.tokenExtractor.getToken() }]; + // Ensure the behalf header is set if impersonating + this.uploader.options.headers = [ + { name: XSRF_REQUEST_HEADER, value: this.tokenExtractor.getToken() }, + ...(hasValue(this.uploadFilesOptions.impersonatingID) + ? [{ name: this.ON_BEHALF_HEADER, value: this.uploadFilesOptions.impersonatingID }] + : []) + ]; this.onBeforeUpload(); this.isOverDocumentDropZone = observableOf(false); }; From 577d2413793207bcf8a90ffbe11f38cf989b72a5 Mon Sep 17 00:00:00 2001 From: Adamo Date: Fri, 2 May 2025 11:04:40 +0200 Subject: [PATCH 4/4] [DURACOM-312] lint fix (cherry picked from commit c68e5a181d006969a1fcfbeba9b3274d21549f6a) --- src/app/shared/upload/uploader/uploader.component.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/shared/upload/uploader/uploader.component.ts b/src/app/shared/upload/uploader/uploader.component.ts index 5bb8a44a77..804200d220 100644 --- a/src/app/shared/upload/uploader/uploader.component.ts +++ b/src/app/shared/upload/uploader/uploader.component.ts @@ -170,10 +170,10 @@ export class UploaderComponent implements OnInit, AfterViewInit { // Ensure the behalf header is set if impersonating this.uploader.options.headers = [ { name: XSRF_REQUEST_HEADER, value: this.tokenExtractor.getToken() }, - ...(hasValue(this.uploadFilesOptions.impersonatingID) - ? [{ name: this.ON_BEHALF_HEADER, value: this.uploadFilesOptions.impersonatingID }] - : []) ]; + if (hasValue(this.uploadFilesOptions.impersonatingID)) { + this.uploader.options.headers.push({ name: this.ON_BEHALF_HEADER, value: this.uploadFilesOptions.impersonatingID }); + } this.onBeforeUpload(); this.isOverDocumentDropZone = observableOf(false); };