Mercurial > hg > orthanc-webviewer
comparison WebApplication/viewer.js @ 219:0f042939410d
support for auth token passed as url search params
author | amazy |
---|---|
date | Tue, 03 Sep 2019 10:56:08 +0200 |
parents | 2f27287c047c |
children | aee499712ac4 |
comparison
equal
deleted
inserted
replaced
218:6318db66448e | 219:0f042939410d |
---|---|
29 if(navigator.appVersion.indexOf("MSIE ") != -1) | 29 if(navigator.appVersion.indexOf("MSIE ") != -1) |
30 { | 30 { |
31 alert("Please use Mozilla Firefox or Google Chrome. Microsoft Internet Explorer is not supported."); | 31 alert("Please use Mozilla Firefox or Google Chrome. Microsoft Internet Explorer is not supported."); |
32 } | 32 } |
33 | 33 |
34 | |
35 function GetAuthorizationTokensFromUrl() { | |
36 var urlVariables = window.location.search.substring(1).split('&'); | |
37 var dict = {}; | |
38 | |
39 for (var i = 0; i < urlVariables.length; i++) { | |
40 var split = urlVariables[i].split('='); | |
41 | |
42 if (split.length == 2 && (split[0] == "token" || split[0] == "auth-token" || split[0] == "authorization")) { | |
43 dict[split[0]] = split[1]; | |
44 } | |
45 } | |
46 return dict; | |
47 }; | |
48 | |
49 var authorizationTokens = GetAuthorizationTokensFromUrl(); | |
50 | |
51 /* Copy the authoziation toekn from the url search parameters into HTTP headers in every request to the Rest API. | |
52 Thanks to this behaviour, you may specify a ?token=xxx in your url and this will be passed | |
53 as the "token" header in every request to the API allowing you to use the authorization plugin */ | |
54 $.ajaxSetup( | |
55 { | |
56 headers : authorizationTokens | |
57 } | |
58 ); | |
34 | 59 |
35 function ResizeCornerstone() | 60 function ResizeCornerstone() |
36 { | 61 { |
37 $('#dicomImage').height($(window).height() - $('#slider').parent().height()); | 62 $('#dicomImage').height($(window).height() - $('#slider').parent().height()); |
38 var element = $('#dicomImage').get(0); | 63 var element = $('#dicomImage').get(0); |