Skip to content

Commit

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

* Fix code locating Bearer token

* Update HttpRequestTest.php
  • Loading branch information
adi64 authored and chu121su12 committed Oct 9, 2021
1 parent efd31c1 commit c497a94
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 c497a94

Please sign in to comment.