Merge pull request #4308 from DSpace/backport-4288-to-dspace-8_x

[Port dspace-8_x] Bitstream upload failure during the workflow editing process when impersonating an editor
This commit is contained in:
Tim Donohue
2025-05-08 08:43:46 -05:00
committed by GitHub
3 changed files with 18 additions and 1 deletions

View File

@@ -22,6 +22,11 @@ export class UploaderOptions {
*/ */
maxFileNumber: number; maxFileNumber: number;
/**
* Impersonating user uuid
*/
impersonatingID: string;
/** /**
* The request method to use for the file upload request * The request method to use for the file upload request
*/ */

View File

@@ -47,6 +47,11 @@ import { UploaderProperties } from './uploader-properties.model';
}) })
export class UploaderComponent implements OnInit, AfterViewInit { 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 * 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; item.url = this.uploader.options.url;
} }
// Ensure the current XSRF token is included in every upload request (token may change between items uploaded) // 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() },
];
if (hasValue(this.uploadFilesOptions.impersonatingID)) {
this.uploader.options.headers.push({ name: this.ON_BEHALF_HEADER, value: this.uploadFilesOptions.impersonatingID });
}
this.onBeforeUpload(); this.onBeforeUpload();
this.isOverDocumentDropZone = observableOf(false); this.isOverDocumentDropZone = observableOf(false);
}; };

View File

@@ -209,6 +209,7 @@ export class SubmissionFormComponent implements OnChanges, OnDestroy {
distinctUntilChanged()) distinctUntilChanged())
.subscribe((endpointURL) => { .subscribe((endpointURL) => {
this.uploadFilesOptions.authToken = this.authService.buildAuthHeader(); this.uploadFilesOptions.authToken = this.authService.buildAuthHeader();
this.uploadFilesOptions.impersonatingID = this.authService.getImpersonateID();
this.uploadFilesOptions.url = endpointURL.concat(`/${this.submissionId}`); this.uploadFilesOptions.url = endpointURL.concat(`/${this.submissionId}`);
this.definitionId = this.submissionDefinition.name; this.definitionId = this.submissionDefinition.name;
this.submissionService.dispatchInit( this.submissionService.dispatchInit(