diff --git a/app/Http/Middleware/ApiAuth.php b/app/Http/Middleware/ApiAuth.php index 3a3082e9..ad4cc757 100644 --- a/app/Http/Middleware/ApiAuth.php +++ b/app/Http/Middleware/ApiAuth.php @@ -23,7 +23,7 @@ class ApiAuth { // Check if Authorization header is in place $auth = $request->header('Authorization', null); - if(empty($auth)) { + if($auth === null) { return $this->unauthorized('Authorization header missing'); } diff --git a/tests/ApiTest.php b/tests/ApiTest.php index c70a023c..8b8476a7 100644 --- a/tests/ApiTest.php +++ b/tests/ApiTest.php @@ -29,6 +29,9 @@ class ApiTest extends TestCase $this->withHeaders(['Authorization' => 'invalidKey'])->get($uri) ->assertStatus(401); + $this->withHeaders(['Authorization' => ''])->get($uri) + ->assertStatus(401); + // Test upper/lower case of Authorization header, etc $this->withHeaders($this->apiHeaders())->get($uri) ->assertStatus(200)