public function handle(Request $request, Closure $next, $requestKey = 'default')
    {
        if (!array_key_exists($requestKey, $this->configurations->get('signed-requests'))) {
            throw new InvalidConfigurationException();
        }

        $signed = new Verifier($request);

        $key = sprintf(
            '%s.%s',
            $this->configurations->get("signed-requests.$requestKey.cache-prefix"),
            $signed->getId()
        );

        $tolerance = $this->configurations->get("signed-requests.$requestKey.request-replay.tolerance");

        if (true !== $this->configurations->get("signed-requests.$requestKey.request-replay.allow")) {
            $isExpired = $signed->isExpired($tolerance);

            if ($isExpired || $this->cache->has($key)) {
                throw new ExpiredRequestException();
            }
        }

        $signed
            ->setSignatureHeader($this->configurations->get("signed-requests.$requestKey.headers.signature"))
            ->setAlgorithmHeader($this->configurations->get("signed-requests.$requestKey.headers.algorithm"));

        if (!$signed->isValid($this->configurations->get("signed-requests.$requestKey.key"))) {
            throw new InvalidSignatureException();
        }

        $this->cache->put($key, $key, $tolerance / 60);

        return $next($request);
    }