2 Commits

Author SHA1 Message Date
86ad0b38dd Monkey Patch XMLHttpRequest -- inject bearer token and verify response 2025-04-29 09:42:53 +07:00
cb380a521d default use cloud pacs 2025-04-29 08:44:52 +07:00
2 changed files with 44 additions and 94 deletions

View File

@@ -1,9 +1,11 @@
/** @type {AppTypes.Config} */
function sas_get_token() {
//implement token here
return "kris-check-token-is-here";
}
window.config = {
sasGetToken: sas_get_token,
routerBasename: '/',
pacs_document_host: '152.42.173.210',
pacs_document_port: 8080,
// whiteLabeling: {},
extensions: [],
modes: [],
@@ -26,10 +28,12 @@ window.config = {
prefetch: 25,
},
expertise: false, //* Tambahan untuk enable expertise (CustomizableViewportOverlay)
expertise_host: `http://152.42.173.210`, //* Tambahan untuk fetch data Expertise)
pacs_document_host: `${window.location.hostname}`,
pacs_document_port: 8080,
// filterQueryParam: false,
// defaultDataSourceName: 'dicomweb',
defaultDataSourceName: 'local-proxy',
// defaultDataSourceName: 'GCP',
/* Dynamic config allows user to pass "configUrl" query string this allows to load config without recompiling application. The regex will ensure valid configuration source */
// dangerouslyUseDynamicConfig: {
// enabled: true,
@@ -45,10 +49,10 @@ window.config = {
namespace: '@ohif/extension-default.dataSourcesModule.dicomweb',
sourceName: 'local-proxy',
configuration: {
friendlyName: 'DCM4CHEE Server',
friendlyName: 'Static WADO Local Data',
name: 'DCM4CHEE',
qidoRoot: 'http://152.42.173.210:5000/rs',
wadoRoot: 'http://152.42.173.210:5000/rs',
qidoRoot: `http://152.42.173.210:5000/rs`,
wadoRoot: `http://152.42.173.210:5000/rs`,
qidoSupportsIncludeField: false,
supportsReject: true,
supportsStow: true,
@@ -58,100 +62,14 @@ window.config = {
supportsFuzzyMatching: false,
supportsWildcard: true,
staticWado: true,
singlepart: 'bulkdata,video',
singlepart: 'video',
bulkDataURI: {
enabled: true,
relativeResolution: 'studies',
transform: url => url.replace('/pixeldata.mp4', '/rendered'),
},
omitQuotationForMultipartRequest: true,
},
},
{
namespace: '@ohif/extension-default.dataSourcesModule.dicomweb',
sourceName: 'dicomweb',
configuration: {
friendlyName: 'AWS S3 Static wado server',
name: 'aws',
wadoUriRoot: 'https://d14fa38qiwhyfd.cloudfront.net/dicomweb',
qidoRoot: 'https://d14fa38qiwhyfd.cloudfront.net/dicomweb',
wadoRoot: 'https://d14fa38qiwhyfd.cloudfront.net/dicomweb',
qidoSupportsIncludeField: false,
imageRendering: 'wadors',
thumbnailRendering: 'wadors',
enableStudyLazyLoad: true,
supportsFuzzyMatching: false,
supportsWildcard: true,
staticWado: true,
singlepart: 'bulkdata,video',
// whether the data source should use retrieveBulkData to grab metadata,
// and in case of relative path, what would it be relative to, options
// are in the series level or study level (some servers like series some study)
bulkDataURI: {
enabled: true,
relativeResolution: 'studies',
transform: url => url.replace('/pixeldata.mp4', '/rendered'),
},
omitQuotationForMultipartRequest: true,
},
},
{
namespace: '@ohif/extension-default.dataSourcesModule.dicomweb',
sourceName: 'ohif2',
configuration: {
friendlyName: 'AWS S3 Static wado secondary server',
name: 'aws',
wadoUriRoot: 'https://dd14fa38qiwhyfd.cloudfront.net/dicomweb',
qidoRoot: 'https://dd14fa38qiwhyfd.cloudfront.net/dicomweb',
wadoRoot: 'https://dd14fa38qiwhyfd.cloudfront.net/dicomweb',
qidoSupportsIncludeField: false,
supportsReject: false,
imageRendering: 'wadors',
thumbnailRendering: 'wadors',
enableStudyLazyLoad: true,
supportsFuzzyMatching: false,
supportsWildcard: true,
staticWado: true,
singlepart: 'bulkdata,video',
// whether the data source should use retrieveBulkData to grab metadata,
// and in case of relative path, what would it be relative to, options
// are in the series level or study level (some servers like series some study)
bulkDataURI: {
enabled: true,
relativeResolution: 'studies',
},
omitQuotationForMultipartRequest: true,
},
},
{
namespace: '@ohif/extension-default.dataSourcesModule.dicomweb',
sourceName: 'ohif3',
configuration: {
friendlyName: 'AWS S3 Static wado secondary server',
name: 'aws',
wadoUriRoot: 'https://d3t6nz73ql33tx.cloudfront.net/dicomweb',
qidoRoot: 'https://d3t6nz73ql33tx.cloudfront.net/dicomweb',
wadoRoot: 'https://d3t6nz73ql33tx.cloudfront.net/dicomweb',
qidoSupportsIncludeField: false,
supportsReject: false,
imageRendering: 'wadors',
thumbnailRendering: 'wadors',
enableStudyLazyLoad: true,
supportsFuzzyMatching: false,
supportsWildcard: true,
staticWado: true,
singlepart: 'bulkdata,video',
// whether the data source should use retrieveBulkData to grab metadata,
// and in case of relative path, what would it be relative to, options
// are in the series level or study level (some servers like series some study)
bulkDataURI: {
enabled: true,
relativeResolution: 'studies',
},
omitQuotationForMultipartRequest: true,
},
},
{
namespace: '@ohif/extension-default.dataSourcesModule.dicomwebproxy',
sourceName: 'dicomwebproxy',

View File

@@ -37,6 +37,38 @@ import appInit from './appInit.js';
import OpenIdConnectRoutes from './utils/OpenIdConnectRoutes';
import { ShepherdJourneyProvider } from 'react-shepherd';
function injectAuth() {
console.log("---> Inject Auth");
const originalXHROpen = XMLHttpRequest.prototype.open;
const originalXHRSend = XMLHttpRequest.prototype.send;
//take from local storage for the token
// let authToken = '--kris-auth-token-check--';
let authToken = window.config.sasGetToken();
XMLHttpRequest.prototype.open = function (method, url, async, user, password) {
this._url = url; // Save URL if you want conditional logic
return originalXHROpen.apply(this, arguments);
};
XMLHttpRequest.prototype.send = function (body) {
this.setRequestHeader('Authorization', `Bearer ${authToken}`);
this.addEventListener('readystatechange', function () {
if (this.readyState === 4) { // DONE
try {
//check responseType ie json, and then check the auth response status
//redirect to custom login page if needed
console.log("response type :", this.responseType);
console.log("response :", this.response);
console.log("responseText :", this.responseText);
} catch (e) { }
}
});
return originalXHRSend.apply(this, arguments);
};
}
injectAuth();
let commandsManager: CommandsManager,
extensionManager: ExtensionManager,
servicesManager: AppTypes.ServicesManager,