diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php
index f049223..e02b2d1 100644
--- a/DependencyInjection/Configuration.php
+++ b/DependencyInjection/Configuration.php
@@ -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()
diff --git a/Resources/views/layout.html.twig b/Resources/views/layout.html.twig
index 87777fc..60d5154 100644
--- a/Resources/views/layout.html.twig
+++ b/Resources/views/layout.html.twig
@@ -26,7 +26,7 @@
- {% if authentication and authentication.delivery in ['query', 'http_basic'] %}
+ {% if authentication and authentication.delivery in ['query', 'http_basic', 'header'] %}
api key:
{% 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 %}