checkToken->checkJwt($this->parserToken($request)); $this->checkIssuer($this->parserToken($request)); return $handler->handle( value( static function (ServerRequestPlusInterface $request, UnencryptedToken $token) { return $request->setAttribute('token', $token); }, $request, $this->getJwt()->parserRefreshToken( $this->getToken($request) ) ) ); } /** * @return JwtInterface */ public function getJwt(): JwtInterface { return $this->jwtFactory->get('admin'); } /** * @param ServerRequestInterface $request * @return UnencryptedToken */ protected function parserToken(ServerRequestInterface $request): UnencryptedToken { return $this->getJwt()->parserRefreshToken($this->getToken($request)); } /** * @param UnencryptedToken $token * @return void */ public function checkIssuer(UnencryptedToken $token): void { $audience = $token->claims()->get(RegisteredClaims::ISSUER); if ($audience !== env('APP_NAME') .'_admin') throw new ErrException('token错误',ResultCode::JWT_ERROR); } }