From bf5b099e2681bc9f3bccf50fee38b9e71bc0b3c8 Mon Sep 17 00:00:00 2001 From: Lari Taskula Date: Tue, 25 Aug 2015 11:58:47 +0000 Subject: [PATCH] Bug 14458: (follow-up) Add checkbox to optionally disable Authorization-header In case you want to test in SwaggerUI without sending the Authorization-header, there is now a checkbox to optionally disable it. --- api/v1/doc/index.html | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/api/v1/doc/index.html b/api/v1/doc/index.html index d645565..3c62c2e 100644 --- a/api/v1/doc/index.html +++ b/api/v1/doc/index.html @@ -79,6 +79,7 @@ }); $('#input_apiKey').change(addApiKeyAuthorization); + $("#useAuthorizationHeader").click(addApiKeyAuthorization); // if you have an apiKey you would like to pre-populate on the page for demonstration purposes... var apiUserid = "1"; @@ -118,19 +119,26 @@ function createSubmitTriggersToInjectAuthorizationHeader() { shaObj.setHMACKey(apikey, "TEXT"); var message = httpVerb.toUpperCase() + " " + userid + " " + date; shaObj.update(message); - var authorizationHeader = "Koha " + userid + ":" + shaObj.getHMAC("HEX"); addApiKeyAuthorization(authorizationHeader); addDateAuthorization(); }); } function addApiKeyAuthorization(headerValue){ + if(!$("#useAuthorizationHeader").is(":checked")){ + window.swaggerUi.api.clientAuthorizations.remove("Authorization"); + return; + } if(headerValue && headerValue.trim() != "") { var apiKeyAuth = new SwaggerClient.ApiKeyAuthorization("Authorization", headerValue, "header"); window.swaggerUi.api.clientAuthorizations.add("Authorization", apiKeyAuth); } } function addDateAuthorization(){ + if(!$("#useAuthorizationHeader").is(":checked")){ + window.swaggerUi.api.clientAuthorizations.remove("X-Koha-Date"); + return; + } var key = $('#dateHeaderInput')[0].value; if(key && key.trim() != "") { var apiKeyAuth = new SwaggerClient.ApiKeyAuthorization("X-Koha-Date", key, "header"); @@ -160,6 +168,10 @@ function addDateAuthorization(){

Authorization-header

+ + + + -- 1.9.1