Skip to content

Commit 97fd42a

Browse files
AdamF42github-actions[bot]
authored andcommitted
[DURACOM-312] set the X-On-Behalf-Of header with impersonatingID in FileUploader.
(cherry picked from commit 727bcdc2cb23ae7fcff1d9ddfa794f872f1d1b8c) (cherry picked from commit 0574c8e)
1 parent 3cff971 commit 97fd42a

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/app/shared/upload/uploader/uploader.component.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ import { DragService } from '../../../core/drag.service';
2323

2424
export class UploaderComponent {
2525

26+
/**
27+
* Header key to impersonate a user
28+
*/
29+
private readonly ON_BEHALF_HEADER = 'X-On-Behalf-Of';
30+
2631
/**
2732
* The message to show when drag files on the drop zone
2833
*/
@@ -139,7 +144,13 @@ export class UploaderComponent {
139144
item.url = this.uploader.options.url;
140145
}
141146
// Ensure the current XSRF token is included in every upload request (token may change between items uploaded)
142-
this.uploader.options.headers = [{ name: XSRF_REQUEST_HEADER, value: this.tokenExtractor.getToken() }];
147+
// Ensure the behalf header is set if impersonating
148+
this.uploader.options.headers = [
149+
{ name: XSRF_REQUEST_HEADER, value: this.tokenExtractor.getToken() },
150+
...(hasValue(this.uploadFilesOptions.impersonatingID)
151+
? [{ name: this.ON_BEHALF_HEADER, value: this.uploadFilesOptions.impersonatingID }]
152+
: [])
153+
];
143154
this.onBeforeUpload();
144155
this.isOverDocumentDropZone = observableOf(false);
145156
};

0 commit comments

Comments
 (0)