feat: set the authorization header for DICOMWeb requests if provided in query string (#1646)
This commit is contained in:
1 parent
d3eefb50f5
commit
450c80b9d5
5 files changed
+257
-75
No files matched your search
@@ -0,0 +1,11 @@
|
||||
import { useLocation } from 'react-router-dom';
|
||||
|
||||
/**
|
||||
* hook that builds on useLocation to parse
|
||||
* the query string for you.
|
||||
*
|
||||
* @name useQuery
|
||||
*/
|
||||
export default function() {
|
||||
return new URLSearchParams(useLocation().search);
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { utils, user } from '@ohif/core';
|
||||
//
|
||||
import ConnectedViewerRetrieveStudyData from '../connectedComponents/ConnectedViewerRetrieveStudyData';
|
||||
import useServer from '../customHooks/useServer';
|
||||
import OHIF from '@ohif/core';
|
||||
const { urlUtil: UrlUtil } = OHIF.utils;
|
||||
import useQuery from '../customHooks/useQuery';
|
||||
const { urlUtil: UrlUtil } = utils;
|
||||
|
||||
/**
|
||||
* Get array of seriesUIDs from param or from queryString
|
||||
@@ -27,8 +29,19 @@ function ViewerRouting({ match: routeMatch, location: routeLocation }) {
|
||||
studyInstanceUIDs,
|
||||
seriesInstanceUIDs,
|
||||
} = routeMatch.params;
|
||||
const server = useServer({ project, location, dataset, dicomStore });
|
||||
|
||||
// Set the user's default authToken for outbound DICOMWeb requests.
|
||||
// Is only applied if target server does not set `requestOptions` property.
|
||||
//
|
||||
// See: `getAuthorizationHeaders.js`
|
||||
let query = useQuery();
|
||||
const authToken = query.get('token');
|
||||
|
||||
if (authToken) {
|
||||
user.getAccessToken = () => authToken;
|
||||
}
|
||||
|
||||
const server = useServer({ project, location, dataset, dicomStore });
|
||||
const studyUIDs = UrlUtil.paramString.parseParam(studyInstanceUIDs);
|
||||
const seriesUIDs = getSeriesInstanceUIDs(seriesInstanceUIDs, routeLocation);
|
||||
|
||||
@@ -55,6 +68,7 @@ ViewerRouting.propTypes = {
|
||||
project: PropTypes.string,
|
||||
}),
|
||||
}),
|
||||
location: PropTypes.any,
|
||||
};
|
||||
|
||||
export default ViewerRouting;
|
||||
@@ -19,7 +19,9 @@ const StudyListRouting = asyncComponent(() =>
|
||||
)
|
||||
);
|
||||
const StandaloneRouting = asyncComponent(() =>
|
||||
import(/* webpackChunkName: "ConnectedStandaloneRouting" */ '../connectedComponents/ConnectedStandaloneRouting.js')
|
||||
import(
|
||||
/* webpackChunkName: "ConnectedStandaloneRouting" */ '../connectedComponents/ConnectedStandaloneRouting.js'
|
||||
)
|
||||
);
|
||||
const ViewerLocalFileData = asyncComponent(() =>
|
||||
import(
|
||||
|
||||
Reference in new issue
Block a user