Mercurial > hg > orthanc-stone
comparison Applications/StoneWebViewer/WebApplication/app.js @ 1959:889892e51545
Fix handling of "token": The authorization header was not set in QIDO-RS requests
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 27 Oct 2022 17:09:28 +0200 |
parents | 142c7ee8fe1f |
children | 2034ae383cfd b180233143ae |
comparison
equal
deleted
inserted
replaced
1958:142c7ee8fe1f | 1959:889892e51545 |
---|---|
1145 }); | 1145 }); |
1146 | 1146 |
1147 | 1147 |
1148 | 1148 |
1149 window.addEventListener('StoneInitialized', function() { | 1149 window.addEventListener('StoneInitialized', function() { |
1150 /** | |
1151 * Do NOT modify the order of the calls to "stone.XXX()" in this | |
1152 * section, otherwise the HTTP headers might not be properly set. | |
1153 **/ | |
1154 | |
1150 stone.Setup(Module); | 1155 stone.Setup(Module); |
1151 stone.SetDicomWebRoot(app.globalConfiguration.DicomWebRoot, | 1156 stone.SetDicomWebRoot(app.globalConfiguration.DicomWebRoot, |
1152 true /* assume "/rendered" is available in DICOMweb (could be a configuration option) */); | 1157 true /* assume "/rendered" is available in DICOMweb (could be a configuration option) */); |
1153 stone.SetSoftwareRendering(localStorage.settingSoftwareRendering == '1'); | 1158 stone.SetSoftwareRendering(localStorage.settingSoftwareRendering == '1'); |
1154 | 1159 |
1155 if ('DicomCacheSize' in app.globalConfiguration) { | 1160 if ('DicomCacheSize' in app.globalConfiguration) { |
1156 stone.SetDicomCacheSize(app.globalConfiguration.DicomCacheSize); | 1161 stone.SetDicomCacheSize(app.globalConfiguration.DicomCacheSize); |
1157 } | 1162 } |
1158 | 1163 |
1164 // Calls to "stone.AddHttpHeader()" must be after "stone.SetDicomWebRoot()", | |
1165 // and before "stone.SetSkipSeriesFromModalities()" | |
1166 for (var header in app.globalConfiguration.DicomWebHttpHeaders) { | |
1167 stone.AddHttpHeader(header, app.globalConfiguration.DicomWebHttpHeaders[header]); | |
1168 } | |
1169 | |
1170 // Bearer token is new in Stone Web viewer 2.0 | |
1171 var token = getParameterFromUrl('token'); | |
1172 if (token !== undefined) { | |
1173 stone.AddHttpHeader('Authorization', 'Bearer ' + token); | |
1174 } | |
1175 | |
1176 | |
1177 /** | |
1178 * Calls to "stone.XXX()" can be reordered after this point. | |
1179 **/ | |
1180 | |
1159 if ('SkipSeriesFromModalities' in app.globalConfiguration) { | 1181 if ('SkipSeriesFromModalities' in app.globalConfiguration) { |
1160 stone.SetSkipSeriesFromModalities(JSON.stringify(app.globalConfiguration.SkipSeriesFromModalities)); | 1182 stone.SetSkipSeriesFromModalities(JSON.stringify(app.globalConfiguration.SkipSeriesFromModalities)); |
1161 } | 1183 } |
1162 | 1184 |
1163 if (app.globalConfiguration.ShowInfoPanelAtStartup == 'Always') { | 1185 if (app.globalConfiguration.ShowInfoPanelAtStartup == 'Always') { |
1168 app.modalNotDiagnostic = app.settingNotDiagnostic; | 1190 app.modalNotDiagnostic = app.settingNotDiagnostic; |
1169 } else { | 1191 } else { |
1170 alert('Bad value for option "ShowInfoPanelAtStartup": ' + app.globalConfiguration.ShowInfoPanelAtStartup); | 1192 alert('Bad value for option "ShowInfoPanelAtStartup": ' + app.globalConfiguration.ShowInfoPanelAtStartup); |
1171 } | 1193 } |
1172 | 1194 |
1173 // Bearer token is new in Stone Web viewer 2.0 | |
1174 var token = getParameterFromUrl('token'); | |
1175 if (token !== undefined) { | |
1176 stone.AddHttpHeader('Authorization', 'Bearer ' + token); | |
1177 } | |
1178 | |
1179 console.warn('Stone properly initialized'); | 1195 console.warn('Stone properly initialized'); |
1180 | 1196 |
1181 app.stoneWebViewerVersion = stone.GetStoneWebViewerVersion(); | 1197 app.stoneWebViewerVersion = stone.GetStoneWebViewerVersion(); |
1182 app.emscriptenVersion = stone.GetEmscriptenVersion(); | 1198 app.emscriptenVersion = stone.GetEmscriptenVersion(); |
1183 | 1199 |