php-http / HttplugBundle

Symfony Framework Integration for HTTPlug
http://httplug.io
MIT License
381 stars 50 forks source link

feat: header authentication service configuration #438

Closed soullivaneuh closed 11 months ago

soullivaneuh commented 11 months ago
Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Related tickets fixes #437
Documentation https://github.com/php-http/documentation/pull/313
License MIT

What's in this PR?

Exposes configuration for the header authentication plugin.

Why?

Allows the direct usage of this plugin through the bundle configuration.

Example Usage

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

Checklist

To Do

N/A

soullivaneuh commented 11 months ago

I am not sure of what I did wrong to make some tests crying. May you give me a hint @dbu?

soullivaneuh commented 11 months ago

I found the reason. Apparently, it is because we are declaring the name scalar value that make the configuration process being confused as name is also used as a key attribute: https://github.com/pocivaneuh/HttplugBundle/blob/32caa9a2c95a4da393a0a91205ea904fe3c53960/src/DependencyInjection/Configuration.php#L640

I changed to key instead: 32caa9a

soullivaneuh commented 11 months ago

All green! :+1: I also updated the documentation PR according to the configuration key name change.

dbu commented 11 months ago

ah right, i think that is for xml where you can't have a custom xml element and we use name as identifier attribute. in yaml its the my_auth: part, and does not need an explicit name.

should we call the thing header_name instead of key? key is a bit generic and could be confusing in the context of security. it boils down to what header name to set in the request.

soullivaneuh commented 11 months ago

Oh that case, header_name and header_value to make things consistent?

dbu commented 11 months ago

yes, i like header_name and header_value. that makes it really clear and leaves no room for confusion (i hope :-) )

soullivaneuh commented 11 months ago

@dbu keys named was changed in 04414b2.

Squashed and rebased, ready for review! :+1: