From 02cc4d1c410249d5dcd876ac51913a0d2111ab4b Mon Sep 17 00:00:00 2001 From: dengjingyuan <602754659@qq.com> Date: Fri, 29 Oct 2021 18:19:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8=E6=B2=A1=E6=9C=89=20authorization=20?= =?UTF-8?q?=EF=BC=8C=E6=9C=89cookie=20=E7=9A=84=E6=83=85=E5=86=B5=E4=B8=8B?= =?UTF-8?q?=EF=BC=8C=E9=80=9A=E8=BF=87cookie=20=E8=8E=B7=E5=8F=96user?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Http/Middleware/AuthenticateWithHeader.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Http/Middleware/AuthenticateWithHeader.php b/src/Http/Middleware/AuthenticateWithHeader.php index a82c072..4b4587b 100644 --- a/src/Http/Middleware/AuthenticateWithHeader.php +++ b/src/Http/Middleware/AuthenticateWithHeader.php @@ -69,6 +69,13 @@ class AuthenticateWithHeader implements MiddlewareInterface $this->getApiFreq($api); $headerLine = $request->getHeaderLine('authorization'); + if(empty($headerLine)){ //如果header头中没有 authorization,则从cookie里面找是否有access_token + $cookies = $request->getCookieParams(); + if(!empty($cookies['access_token'])){ + $headerLine = $cookies['access_token']; + $request = $request->withHeader('authorization', $headerLine); + } + } // 允许 get、cookie 携带 Token if (!$headerLine) { -- Gitee