Skip to content

Commit

Permalink
[8.x] Fix code locating Bearer token in InteractsWithInput (#39150)
Browse files Browse the repository at this point in the history
* Fix code locating Bearer token

* Update HttpRequestTest.php
  • Loading branch information
adi64 authored Oct 8, 2021
1 parent 1e4c57c commit 02bc7ad
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Illuminate/Http/Concerns/InteractsWithInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function bearerToken()
{
$header = $this->header('Authorization', '');

$position = strrpos($header, 'Bearer');
$position = strrpos($header, 'Bearer ');

if ($position !== false) {
$header = substr($header, $position + 7);
Expand Down
4 changes: 2 additions & 2 deletions tests/Http/HttpRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -718,8 +718,8 @@ public function testHeaderMethod()

public function testBearerTokenMethod()
{
$request = Request::create('/', 'GET', [], [], [], ['HTTP_AUTHORIZATION' => 'Bearer foo']);
$this->assertSame('foo', $request->bearerToken());
$request = Request::create('/', 'GET', [], [], [], ['HTTP_AUTHORIZATION' => 'Bearer fooBearerbar']);
$this->assertSame('fooBearerbar', $request->bearerToken());

$request = Request::create('/', 'GET', [], [], [], ['HTTP_AUTHORIZATION' => 'Basic foo, Bearer bar']);
$this->assertSame('bar', $request->bearerToken());
Expand Down

0 comments on commit 02bc7ad

Please sign in to comment.