php-http/HttplugBundle

Header authentication service configuration

soullivaneuh opened this issue · 2 comments

Description

The Header authentication service, introduced in php-http/message@144d13b, is present since v1.9.0 of its related package.

However, it is currently not possible to configure it through the bundle configuration:

switch ($config['type']) {
case 'basic':
$this->validateAuthenticationType(['username', 'password'], $config, 'basic');
break;
case 'bearer':
$this->validateAuthenticationType(['token'], $config, 'bearer');
break;
case 'service':
$this->validateAuthenticationType(['service'], $config, 'service');
break;
case 'wsse':
$this->validateAuthenticationType(['username', 'password'], $config, 'wsse');
break;
case 'query_param':
$this->validateAuthenticationType(['params'], $config, 'query_param');
break;
}

Example

httplug:
  clients:
    sample:
      # ...
      plugins:
        - base_uri:
            uri: "%env(SAMPLE_API_URL)%"
        - authentication:
            header:
              type: header
              name: "ApiKey"
              token: "%env(SAMPLE_API_TOKEN)%"
dbu commented

yeah, that is missing. the place in the configuration you linked is where we should add it indeed.

and update the documentation here and here

for your proposed configuration format, i would make it consistent with the name in the authentication class, so it would be

  - authentication:
      header:
          type: header
          name: "ApiKey"
          value: "%env(SAMPLE_API_TOKEN)%"

do you want to do a pull request for it?

Working on it.