feat(standalone-viewer): Add authorization header (#322)

This commit is contained in:
nicolasvandooren authored and Erik Ziegler committed 2018-12-12 18:01:46 +01:00
1 parent a4b8f2c5ed
commit 947a5f470d
3 files changed
+29

No files matched your search

@@ -21,4 +21,15 @@ Meteor.startup(function() {
cornerstoneWADOImageLoader.webWorkerManager.initialize(config);
cornerstoneWebImageLoader.external.cornerstone = cornerstone;
let configureAuthorization = {
beforeSend: function(xhr){
if (OHIF.viewer.authorizationToken) {
xhr.setRequestHeader('Authorization', OHIF.viewer.authorizationToken);
}
}
};
cornerstoneWADOImageLoader.configure(configureAuthorization);
cornerstoneWebImageLoader.configure(configureAuthorization);
});
@@ -94,6 +94,14 @@ if (Meteor.isClient) {
oReq.open('GET', url);
oReq.setRequestHeader('Accept', 'application/json')
// Add token in the request authorization header
// if a token fragment parameter is present
const tokenParam = this.params.hash ? this.params.hash.match(/(?:token)=(.*?)(?:&|$)/) : null;
if (tokenParam) {
OHIF.viewer.authorizationToken = "Bearer " + tokenParam[1];
oReq.setRequestHeader('Authorization', OHIF.viewer.authorizationToken);
}
// Fire the request to the server
oReq.send();
},