Open IsmailAlamKhan opened 3 months ago
Issue: Bearer Token Not Sent for First Frame API Request in DCM4CHEE
I am passing a Bearer token in two places within the OHIF codebase to authenticate API requests, but the token is not being sent when retrieving the first frame. As a result, the UI breaks. However, for all other API requests, the Bearer token is being sent successfully.
Details:
In extensions/default/src/DicomWebDataSource/index.js:
getAuthorizationHeader = () => {
const xhrRequestHeaders = {};
const authHeaders = userAuthenticationService.getAuthorizationHeader();
if (authHeaders && authHeaders.Authorization) {
xhrRequestHeaders.Authorization = authHeaders.Authorization;
}
xhrRequestHeaders.Authorization = Bearer ${dcm_token}
;
return xhrRequestHeaders;
};
In initWADOImageLoader:
beforeSend: function (xhr) { const dcm_token = sessionStorage.getItem('dcm4chee_token'); const sourceConfig = extensionManager.getActiveDataSource()?.[0].getConfig() ?? {}; const headers = userAuthenticationService.getAuthorizationHeader(); const acceptHeader = utils.generateAcceptHeader( sourceConfig.acceptHeader, sourceConfig.requestTransferSyntaxUID, sourceConfig.omitQuotationForMultipartRequest );
const xhrRequestHeaders = {
Accept: acceptHeader,
};
if (dcm_token) {
xhrRequestHeaders.Authorization = Bearer ${dcm_token}
;
}
if (headers) {
Object.assign(xhrRequestHeaders, headers);
}
return xhrRequestHeaders; } Problem: For the API request to retrieve the first frame, the Bearer token is not being sent, causing the UI to break. For all other subsequent API requests, the Bearer token is correctly included, and the APIs function as expected.
I suspect the issue is related to how the beforeSend logic is handled for the first frame, but I'm unsure how to resolve it. Any guidance or suggestions would be appreciated.
Can you check the latest OHIF viewer, which now includes Cornerstone 3D 2.0?
Here are the migration guides:
Try OHIF locally: https://viewer-dev.ohif.org/localbasic
Try Cornerstone3D 2.0 locally: https://www.cornerstonejs.org/live-examples/local.html
Describe the Bug
We are using OHIF's DICOM viewer as an iframe within our application. Everything is functioning correctly, however, our Orthanc instance is secured with email and password login. We have a basic token which should be passed in the Authorization header for authentication, but I'm having trouble passing this token in the request. I asked about this issue on Slack and was advised to incorporate the Authorization header in the following places:
Steps to Reproduce
The current behavior
The Authorization header is not being included in the requests.
The expected behavior
The Authorization header containing the basic authentication token should be passed with the requests to the Orthanc instance.
OS
MacOS 15.0(beta)
Node version
v21.7.3
Browser
Arc Browser for MacOS v1.54.0(52220)