Skip to content

Commit 0574c8e

Browse files
committed
[DURACOM-312] set the X-On-Behalf-Of header with impersonatingID in FileUploader.
(cherry picked from commit 727bcdc2cb23ae7fcff1d9ddfa794f872f1d1b8c)
1 parent 70c6af3 commit 0574c8e

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
@@ -47,6 +47,11 @@ import { UploaderProperties } from './uploader-properties.model';
4747
})
4848
export class UploaderComponent implements OnInit, AfterViewInit {
4949

50+
/**
51+
* Header key to impersonate a user
52+
*/
53+
private readonly ON_BEHALF_HEADER = 'X-On-Behalf-Of';
54+
5055
/**
5156
* The message to show when drag files on the drop zone
5257
*/
@@ -162,7 +167,13 @@ export class UploaderComponent implements OnInit, AfterViewInit {
162167
item.url = this.uploader.options.url;
163168
}
164169
// Ensure the current XSRF token is included in every upload request (token may change between items uploaded)
165-
this.uploader.options.headers = [{ name: XSRF_REQUEST_HEADER, value: this.tokenExtractor.getToken() }];
170+
// Ensure the behalf header is set if impersonating
171+
this.uploader.options.headers = [
172+
{ name: XSRF_REQUEST_HEADER, value: this.tokenExtractor.getToken() },
173+
...(hasValue(this.uploadFilesOptions.impersonatingID)
174+
? [{ name: this.ON_BEHALF_HEADER, value: this.uploadFilesOptions.impersonatingID }]
175+
: [])
176+
];
166177
this.onBeforeUpload();
167178
this.isOverDocumentDropZone = observableOf(false);
168179
};

0 commit comments

Comments
 (0)