From 23e07689a78b1cb486baa3e4838b858a02f0a661 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Tue, 27 Feb 2018 21:04:04 -0600 Subject: [PATCH] Handle 404 errors in API bindings correctly to avoid explosing that a resource exists before validating a key --- CHANGELOG.md | 1 + app/Http/Middleware/Api/ApiSubstituteBindings.php | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bbed28aac..a3e47a3b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines. ## v0.7.4 (Derelict Dermodactylus) ### Fixed * Fixes a bug when reinstalling a server that would not mark the server as installing, resulting in some UI issues. +* Handle 404 errors from missing models in the application API bindings correctly. ## v0.7.3 (Derelict Dermodactylus) ### Fixed diff --git a/app/Http/Middleware/Api/ApiSubstituteBindings.php b/app/Http/Middleware/Api/ApiSubstituteBindings.php index b270be4ca..a56a3426f 100644 --- a/app/Http/Middleware/Api/ApiSubstituteBindings.php +++ b/app/Http/Middleware/Api/ApiSubstituteBindings.php @@ -45,7 +45,9 @@ class ApiSubstituteBindings extends SubstituteBindings $route = $request->route(); foreach (self::$mappings as $key => $model) { - $this->router->model($key, $model); + $this->router->model($key, $model, function () use ($request) { + $request->attributes->set('is_missing_model', true); + }); } $this->router->substituteBindings($route);