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()
|
->isRequired()
|
||||||
->validate()
|
->validate()
|
||||||
// header|query|request, but only query is implemented for now
|
// 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'.")
|
->thenInvalid("Unknown authentication delivery type '%s'.")
|
||||||
->end()
|
->end()
|
||||||
->end()
|
->end()
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
<option value="json"{{ defaultRequestFormat == 'json' ? ' selected' : '' }}>JSON</option>
|
<option value="json"{{ defaultRequestFormat == 'json' ? ' selected' : '' }}>JSON</option>
|
||||||
<option value="xml"{{ defaultRequestFormat == 'xml' ? ' selected' : '' }}>XML</option>
|
<option value="xml"{{ defaultRequestFormat == 'xml' ? ' selected' : '' }}>XML</option>
|
||||||
</select>
|
</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=""/>
|
api key: <input type="text" id="api_key" value=""/>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if authentication and authentication.delivery in ['http_basic'] %}
|
{% if authentication and authentication.delivery in ['http_basic'] %}
|
||||||
@ -271,6 +271,8 @@
|
|||||||
beforeSend: function (xhr) {
|
beforeSend: function (xhr) {
|
||||||
if (authentication_delivery == 'http_basic') {
|
if (authentication_delivery == 'http_basic') {
|
||||||
xhr.setRequestHeader('Authorization', 'Basic ' + btoa($('#api_key').val() + ':' + $('#api_pass').val()));
|
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) {
|
complete: function(xhr) {
|
||||||
@ -372,6 +374,9 @@
|
|||||||
|
|
||||||
$('#api_key').val(api_key);
|
$('#api_key').val(api_key);
|
||||||
}
|
}
|
||||||
|
{% elseif authentication and authentication.delivery == 'header' %}
|
||||||
|
var authentication_delivery = '{{ authentication.delivery }}';
|
||||||
|
var api_key_parameter = '{{ authentication.name }}';
|
||||||
{% else %}
|
{% else %}
|
||||||
var authentication_delivery = false;
|
var authentication_delivery = false;
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user