Skip to content

Commit 4da51a0

Browse files
committed
fixes authentication errors when not using basic authentication
1 parent c5aa5f7 commit 4da51a0

File tree

4 files changed

+24
-22
lines changed

4 files changed

+24
-22
lines changed

src/Authentication/KerberosAuth.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
namespace Laudis\Neo4j\Authentication;
1515

1616
use Bolt\helpers\Auth;
17+
use Bolt\protocol\Response;
1718
use Bolt\protocol\V4_4;
1819
use Bolt\protocol\V5;
1920
use Laudis\Neo4j\Contracts\AuthenticateInterface;
21+
use Laudis\Neo4j\Exception\Neo4jException;
2022
use Psr\Http\Message\RequestInterface;
2123
use Psr\Http\Message\UriInterface;
2224

@@ -50,8 +52,13 @@ public function authenticateHttp(RequestInterface $request, UriInterface $uri, s
5052

5153
public function authenticateBolt(V4_4|V5 $bolt, string $userAgent): array
5254
{
55+
$response = $bolt->hello(Auth::kerberos($this->token, $userAgent));
56+
if ($response->getSignature() === Response::SIGNATURE_FAILURE) {
57+
throw Neo4jException::fromBoltResponse($response);
58+
}
59+
5360
/** @var array{server: string, connection_id: string, hints: list} */
54-
return $bolt->hello(Auth::bearer($this->token, $userAgent));
61+
return $response->getContent();
5562
}
5663

5764
public function toString(UriInterface $uri): string

src/Authentication/NoAuth.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
namespace Laudis\Neo4j\Authentication;
1515

1616
use Bolt\helpers\Auth;
17+
use Bolt\protocol\Response;
1718
use Bolt\protocol\V4_4;
1819
use Bolt\protocol\V5;
1920
use Laudis\Neo4j\Contracts\AuthenticateInterface;
21+
use Laudis\Neo4j\Exception\Neo4jException;
2022
use Psr\Http\Message\RequestInterface;
2123
use Psr\Http\Message\UriInterface;
2224

@@ -42,8 +44,13 @@ public function authenticateHttp(RequestInterface $request, UriInterface $uri, s
4244

4345
public function authenticateBolt(V4_4|V5 $bolt, string $userAgent): array
4446
{
47+
$response = $bolt->hello(Auth::none($userAgent));
48+
if ($response->getSignature() === Response::SIGNATURE_FAILURE) {
49+
throw Neo4jException::fromBoltResponse($response);
50+
}
51+
4552
/** @var array{server: string, connection_id: string, hints: list} */
46-
return $bolt->hello(Auth::none($userAgent));
53+
return $response->getContent();
4754
}
4855

4956
public function toString(UriInterface $uri): string

src/Authentication/OpenIDConnectAuth.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
namespace Laudis\Neo4j\Authentication;
1515

1616
use Bolt\helpers\Auth;
17+
use Bolt\protocol\Response;
1718
use Bolt\protocol\V4_4;
1819
use Bolt\protocol\V5;
1920
use Laudis\Neo4j\Contracts\AuthenticateInterface;
21+
use Laudis\Neo4j\Exception\Neo4jException;
2022
use Psr\Http\Message\RequestInterface;
2123
use Psr\Http\Message\UriInterface;
2224

@@ -47,8 +49,13 @@ public function authenticateHttp(RequestInterface $request, UriInterface $uri, s
4749

4850
public function authenticateBolt(V4_4|V5 $bolt, string $userAgent): array
4951
{
52+
$response = $bolt->hello(Auth::bearer($this->token, $userAgent));
53+
if ($response->getSignature() === Response::SIGNATURE_FAILURE) {
54+
throw Neo4jException::fromBoltResponse($response);
55+
}
56+
5057
/** @var array{server: string, connection_id: string, hints: list} */
51-
return $bolt->hello(Auth::bearer($this->token));
58+
return $response->getContent();
5259
}
5360

5461
public function toString(UriInterface $uri): string

tests/bootstrap_override_with_dotenv.php

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)