# HG changeset patch # User Alain Mazy # Date 1567496950 -7200 # Node ID 5405d51e040d152662e78f05e9fe83104ff4cca1 # Parent 70524b4acc726adc6a63ecb5540b0586ed429165 Orthanc Explorer: include the url search params into HTTP headers to the Rest API to ease usage of the Authorization plugin diff -r 70524b4acc72 -r 5405d51e040d NEWS --- a/NEWS Thu Aug 29 11:41:26 2019 +0200 +++ b/NEWS Tue Sep 03 09:49:10 2019 +0200 @@ -9,6 +9,7 @@ * Name of temporary files now include the process ID to ease design of scripts cleaning /tmp * Fix compatibility of LSB binaries with Ubuntu >= 18.04 * Fix generation of "SOP Instance UID" on split and merge +* Orthanc Explorer: include the url search params into HTTP headers to the Rest API to ease usage of the Authorization plugin Version 1.5.7 (2019-06-25) diff -r 70524b4acc72 -r 5405d51e040d OrthancExplorer/explorer.js --- a/OrthancExplorer/explorer.js Thu Aug 29 11:41:26 2019 +0200 +++ b/OrthancExplorer/explorer.js Tue Sep 03 09:49:10 2019 +0200 @@ -91,6 +91,31 @@ } }); +var GetUrlParametersAsDict = function getUrlParametersAsDict(sParam) { + var urlVariables = window.location.search.substring(1).split('&'); + var dict = {}; + + for (var i = 0; i < urlVariables.length; i++) { + var split = urlVariables[i].split('='); + + if (split.length == 2) { + dict[split[0]] = split[1]; + } + } + return dict; +}; + +var initSearchParams = GetUrlParametersAsDict(); + +/* Copy all url search parameters into HTTP headers in every request to the Rest API. +Thanks to this behaviour, you may specify a ?token=xxx in your url and this will be passed +as the "token" header in every request to the API allowing you to use the authorization plugin */ +$.ajaxSetup( + { + headers : initSearchParams + } +); + function SplitLongUid(s) {