mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 15:51:48 +03:00
Adds custom header Authentication method
This commit is contained in:
parent
a8957a5915
commit
7f2cff2ac5
@ -70,7 +70,7 @@ class Configuration implements ConfigurationInterface
|
||||
->isRequired()
|
||||
->validate()
|
||||
// header|query|request, but only query is implemented for now
|
||||
->ifNotInArray(array('query', 'http_basic'))
|
||||
->ifNotInArray(array('query', 'http_basic', 'header'))
|
||||
->thenInvalid("Unknown authentication delivery type '%s'.")
|
||||
->end()
|
||||
->end()
|
||||
|
@ -26,7 +26,7 @@
|
||||
<option value="json"{{ defaultRequestFormat == 'json' ? ' selected' : '' }}>JSON</option>
|
||||
<option value="xml"{{ defaultRequestFormat == 'xml' ? ' selected' : '' }}>XML</option>
|
||||
</select>
|
||||
{% if authentication and authentication.delivery in ['query', 'http_basic'] %}
|
||||
{% if authentication and authentication.delivery in ['query', 'http_basic', 'header'] %}
|
||||
api key: <input type="text" id="api_key" value=""/>
|
||||
{% endif %}
|
||||
{% if authentication and authentication.delivery in ['http_basic'] %}
|
||||
@ -271,6 +271,8 @@
|
||||
beforeSend: function (xhr) {
|
||||
if (authentication_delivery == 'http_basic') {
|
||||
xhr.setRequestHeader('Authorization', 'Basic ' + btoa($('#api_key').val() + ':' + $('#api_pass').val()));
|
||||
}else if(authentication_delivery == 'header') {
|
||||
xhr.setRequestHeader(api_key_parameter, $('#api_key').val());
|
||||
}
|
||||
},
|
||||
complete: function(xhr) {
|
||||
@ -372,6 +374,9 @@
|
||||
|
||||
$('#api_key').val(api_key);
|
||||
}
|
||||
{% elseif authentication and authentication.delivery == 'header' %}
|
||||
var authentication_delivery = '{{ authentication.delivery }}';
|
||||
var api_key_parameter = '{{ authentication.name }}';
|
||||
{% else %}
|
||||
var authentication_delivery = false;
|
||||
{% endif %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user