From 8c782a00e92bbe2e29130e71136b2eef6c291585 Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Thu, 5 Oct 2017 12:26:05 +1030 Subject: [PATCH] Add the ApiKey model as a request attribute --- framework/core/src/Http/Middleware/AuthenticateWithHeader.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/framework/core/src/Http/Middleware/AuthenticateWithHeader.php b/framework/core/src/Http/Middleware/AuthenticateWithHeader.php index 1bf1fd51b..dfb3f8e9c 100644 --- a/framework/core/src/Http/Middleware/AuthenticateWithHeader.php +++ b/framework/core/src/Http/Middleware/AuthenticateWithHeader.php @@ -35,9 +35,10 @@ class AuthenticateWithHeader implements MiddlewareInterface $id = substr($parts[0], strlen(self::TOKEN_PREFIX)); if (isset($parts[1])) { - if (ApiKey::find($id)) { + if ($key = ApiKey::find($id)) { $actor = $this->getUser($parts[1]); + $request = $request->withAttribute('apiKey', $key); $request = $request->withAttribute('bypassFloodgate', true); } } elseif ($token = AccessToken::find($id)) {