response = $response; $this->jwt = $jwt; } /** * @param ServerRequestInterface $request * @param RequestHandlerInterface $handler * @return ResponseInterface * @throws \Psr\SimpleCache\InvalidArgumentException * @throws \Throwable */ public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { // 判断是否为noCheckRoute $path = $request->getUri()->getPath(); $method = $request->getMethod(); if ($this->jwt->matchRoute('application2', $method, $path)) { return $handler->handle($request); } $token = $request->getHeaderLine('Authorization') ?? ''; if ($token == "") { throw new JWTException('Missing token', 400); } $token = JWTUtil::handleToken($token); if ($token !== false && $this->jwt->verifyTokenAndScene('application2', $token)) { return $handler->handle($request); } throw new TokenValidException('Token authentication does not pass', 400); } }