File tree Expand file tree Collapse file tree 3 files changed +68
-0
lines changed Expand file tree Collapse file tree 3 files changed +68
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
99
1010## Unreleased
1111
12+ ### Added
13+
14+ - New Header authentication method for arbitrary header authentication.
15+
1216## [ 1.8.0] - 2019-08-05
1317
1418### Changed
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace spec \Http \Message \Authentication ;
4+
5+ use PhpSpec \ObjectBehavior ;
6+ use Psr \Http \Message \RequestInterface ;
7+
8+ class HeaderSpec extends ObjectBehavior
9+ {
10+ function let ()
11+ {
12+ $ this ->beConstructedWith ('X-AUTH-TOKEN ' , 'REAL ' );
13+ }
14+
15+ function it_is_initializable ()
16+ {
17+ $ this ->shouldHaveType ('Http\Message\Authentication\Header ' );
18+ }
19+
20+ function it_is_an_authentication ()
21+ {
22+ $ this ->shouldImplement ('Http\Message\Authentication ' );
23+ }
24+
25+ function it_authenticates_a_request (RequestInterface $ request , RequestInterface $ newRequest )
26+ {
27+ $ request ->withHeader ('X-AUTH-TOKEN ' , 'REAL ' )->willReturn ($ newRequest );
28+
29+ $ this ->authenticate ($ request )->shouldReturn ($ newRequest );
30+ }
31+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Http \Message \Authentication ;
4+
5+ use Http \Message \Authentication ;
6+ use Psr \Http \Message \RequestInterface ;
7+
8+ class Header implements Authentication
9+ {
10+ /**
11+ * @var string
12+ */
13+ private $ name ;
14+
15+ /**
16+ * @var string|array
17+ */
18+ private $ value ;
19+
20+ public function __construct (string $ name , $ value )
21+ {
22+ $ this ->name = $ name ;
23+ $ this ->value = $ value ;
24+ }
25+
26+ /**
27+ * {@inheritdoc}
28+ */
29+ public function authenticate (RequestInterface $ request )
30+ {
31+ return $ request ->withHeader ($ this ->name , $ this ->value );
32+ }
33+ }
You can’t perform that action at this time.
0 commit comments