View | Details | Raw Unified | Return to bug 14458
Collapse All | Expand All

(-)a/api/v1/doc/index.html (-2 / +13 lines)
Lines 79-84 Link Here
79
      });
79
      });
80
80
81
      $('#input_apiKey').change(addApiKeyAuthorization);
81
      $('#input_apiKey').change(addApiKeyAuthorization);
82
      $("#useAuthorizationHeader").click(addApiKeyAuthorization);
82
83
83
      // if you have an apiKey you would like to pre-populate on the page for demonstration purposes...
84
      // if you have an apiKey you would like to pre-populate on the page for demonstration purposes...
84
      var apiUserid = "1";
85
      var apiUserid = "1";
Lines 118-136 function createSubmitTriggersToInjectAuthorizationHeader() { Link Here
118
        shaObj.setHMACKey(apikey, "TEXT");
119
        shaObj.setHMACKey(apikey, "TEXT");
119
        var message = httpVerb.toUpperCase() + " " + userid + " " + date;
120
        var message = httpVerb.toUpperCase() + " " + userid + " " + date;
120
        shaObj.update(message);
121
        shaObj.update(message);
121
122
        var authorizationHeader = "Koha " + userid + ":" + shaObj.getHMAC("HEX");
122
        var authorizationHeader = "Koha " + userid + ":" + shaObj.getHMAC("HEX");
123
        addApiKeyAuthorization(authorizationHeader);
123
        addApiKeyAuthorization(authorizationHeader);
124
        addDateAuthorization();
124
        addDateAuthorization();
125
    });
125
    });
126
}
126
}
127
function addApiKeyAuthorization(headerValue){
127
function addApiKeyAuthorization(headerValue){
128
    if(!$("#useAuthorizationHeader").is(":checked")){
129
        window.swaggerUi.api.clientAuthorizations.remove("Authorization");
130
        return;
131
    }
128
    if(headerValue && headerValue.trim() != "") {
132
    if(headerValue && headerValue.trim() != "") {
129
        var apiKeyAuth = new SwaggerClient.ApiKeyAuthorization("Authorization", headerValue, "header");
133
        var apiKeyAuth = new SwaggerClient.ApiKeyAuthorization("Authorization", headerValue, "header");
130
        window.swaggerUi.api.clientAuthorizations.add("Authorization", apiKeyAuth);
134
        window.swaggerUi.api.clientAuthorizations.add("Authorization", apiKeyAuth);
131
    }
135
    }
132
}
136
}
133
function addDateAuthorization(){
137
function addDateAuthorization(){
138
  if(!$("#useAuthorizationHeader").is(":checked")){
139
      window.swaggerUi.api.clientAuthorizations.remove("X-Koha-Date");
140
      return;
141
  }
134
  var key = $('#dateHeaderInput')[0].value;
142
  var key = $('#dateHeaderInput')[0].value;
135
  if(key && key.trim() != "") {
143
  if(key && key.trim() != "") {
136
      var apiKeyAuth = new SwaggerClient.ApiKeyAuthorization("X-Koha-Date", key, "header");
144
      var apiKeyAuth = new SwaggerClient.ApiKeyAuthorization("X-Koha-Date", key, "header");
Lines 160-165 function addDateAuthorization(){ Link Here
160
          <td colspan="2"><h3>Authorization-header</h3></td>
168
          <td colspan="2"><h3>Authorization-header</h3></td>
161
        </tr>
169
        </tr>
162
        <tr>
170
        <tr>
171
          <td><label for="useAuthorizationHeader">Use Authorization-header:</label></td>
172
          <td><input type="checkbox" id="useAuthorizationHeader" name="useAuthorizationHeader" checked="checked" />
173
        </tr>
174
        <tr>
163
          <td><label for="input_apiUserid">Userid:</label></td>
175
          <td><label for="input_apiUserid">Userid:</label></td>
164
          <td><input placeholder="api_userid" id="input_apiUserid" name="apiUserid" type="text" style="width:100%"/></td>
176
          <td><input placeholder="api_userid" id="input_apiUserid" name="apiUserid" type="text" style="width:100%"/></td>
165
        </tr>
177
        </tr>
166
- 

Return to bug 14458