# HG changeset patch # User Sebastien Jodogne # Date 1666883368 -7200 # Node ID 889892e51545c34679039d4ebd4d02b2cb4750f7 # Parent 142c7ee8fe1fdee9b3b0f57dca9e7b4015a52544 Fix handling of "token": The authorization header was not set in QIDO-RS requests diff -r 142c7ee8fe1f -r 889892e51545 Applications/StoneWebViewer/NEWS --- a/Applications/StoneWebViewer/NEWS Thu Oct 27 14:53:09 2022 +0200 +++ b/Applications/StoneWebViewer/NEWS Thu Oct 27 17:09:28 2022 +0200 @@ -5,8 +5,10 @@ - "ShowInfoPanelAtStartup" to control the info panel at startup - "ShowUserPreferencesButton" to show the button for setting preferences - "ShowNotForDiagnosticUsageDisclaimer" to show disclaimer about diagnostic usage + - "DicomWebHttpHeaders" to set HTTP headers in DICOMweb requests * More tolerance wrt. bad values of the Pixel Spacing (0028,0030) tag * Support of DICOM images without the Study Date (0008,0020) tag +* Fix handling of "token": The authorization header was not set in QIDO-RS requests Version 2.3 (2022-03-24) diff -r 142c7ee8fe1f -r 889892e51545 Applications/StoneWebViewer/WebApplication/app.js --- a/Applications/StoneWebViewer/WebApplication/app.js Thu Oct 27 14:53:09 2022 +0200 +++ b/Applications/StoneWebViewer/WebApplication/app.js Thu Oct 27 17:09:28 2022 +0200 @@ -1147,6 +1147,11 @@ window.addEventListener('StoneInitialized', function() { + /** + * Do NOT modify the order of the calls to "stone.XXX()" in this + * section, otherwise the HTTP headers might not be properly set. + **/ + stone.Setup(Module); stone.SetDicomWebRoot(app.globalConfiguration.DicomWebRoot, true /* assume "/rendered" is available in DICOMweb (could be a configuration option) */); @@ -1156,6 +1161,23 @@ stone.SetDicomCacheSize(app.globalConfiguration.DicomCacheSize); } + // Calls to "stone.AddHttpHeader()" must be after "stone.SetDicomWebRoot()", + // and before "stone.SetSkipSeriesFromModalities()" + for (var header in app.globalConfiguration.DicomWebHttpHeaders) { + stone.AddHttpHeader(header, app.globalConfiguration.DicomWebHttpHeaders[header]); + } + + // Bearer token is new in Stone Web viewer 2.0 + var token = getParameterFromUrl('token'); + if (token !== undefined) { + stone.AddHttpHeader('Authorization', 'Bearer ' + token); + } + + + /** + * Calls to "stone.XXX()" can be reordered after this point. + **/ + if ('SkipSeriesFromModalities' in app.globalConfiguration) { stone.SetSkipSeriesFromModalities(JSON.stringify(app.globalConfiguration.SkipSeriesFromModalities)); } @@ -1170,12 +1192,6 @@ alert('Bad value for option "ShowInfoPanelAtStartup": ' + app.globalConfiguration.ShowInfoPanelAtStartup); } - // Bearer token is new in Stone Web viewer 2.0 - var token = getParameterFromUrl('token'); - if (token !== undefined) { - stone.AddHttpHeader('Authorization', 'Bearer ' + token); - } - console.warn('Stone properly initialized'); app.stoneWebViewerVersion = stone.GetStoneWebViewerVersion(); diff -r 142c7ee8fe1f -r 889892e51545 Applications/StoneWebViewer/WebApplication/configuration.json --- a/Applications/StoneWebViewer/WebApplication/configuration.json Thu Oct 27 14:53:09 2022 +0200 +++ b/Applications/StoneWebViewer/WebApplication/configuration.json Thu Oct 27 17:09:28 2022 +0200 @@ -139,6 +139,15 @@ * Display a "not for diagnostic usage" disclaimer above the list * of studies/series. (New in Stone Web viewer 2.4) **/ - "ShowNotForDiagnosticUsageDisclaimer": true + "ShowNotForDiagnosticUsageDisclaimer": true, + + /** + * HTTP headers to be set in each request to the DICOMweb server. + * Note that the value of the headers can be taken from the + * environment variables. + **/ + "DicomWebHttpHeaders" : { + /* "Authorization" : "Bearer ${USER}" */ + } } }