getHeaderKey($request); if (sha1($this->api_key) === $key) { return true; } return false; } protected function getHeaderKey(ServerRequestInterface $request): string { if (!$request->hasHeader('Authorization')) { throw new Unauthorized(); } $auths = $request->getHeader('Authorization'); foreach ($auths as $auth) { if (str_contains($auth, 'Bearer')) { return str_replace('Bearer ', '', $auth); } } throw new Unauthorized(); } }