diff --git a/CHANGELOG.md b/CHANGELOG.md index 93427cb..6a29df8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## Unreleased +### Added + +- New Header authentication method for arbitrary header authentication. + ## [1.8.0] - 2019-08-05 ### Changed diff --git a/spec/Authentication/HeaderSpec.php b/spec/Authentication/HeaderSpec.php new file mode 100644 index 0000000..b6ee348 --- /dev/null +++ b/spec/Authentication/HeaderSpec.php @@ -0,0 +1,31 @@ +beConstructedWith('X-AUTH-TOKEN', 'REAL'); + } + + function it_is_initializable() + { + $this->shouldHaveType('Http\Message\Authentication\Header'); + } + + function it_is_an_authentication() + { + $this->shouldImplement('Http\Message\Authentication'); + } + + function it_authenticates_a_request(RequestInterface $request, RequestInterface $newRequest) + { + $request->withHeader('X-AUTH-TOKEN', 'REAL')->willReturn($newRequest); + + $this->authenticate($request)->shouldReturn($newRequest); + } +} diff --git a/src/Authentication/Header.php b/src/Authentication/Header.php new file mode 100644 index 0000000..97a04dd --- /dev/null +++ b/src/Authentication/Header.php @@ -0,0 +1,33 @@ +name = $name; + $this->value = $value; + } + + /** + * {@inheritdoc} + */ + public function authenticate(RequestInterface $request) + { + return $request->withHeader($this->name, $this->value); + } +}