Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ test

#PHP-CS-FIXER
.php-cs-fixer.php
.php-cs-fixer.cache
.php-cs-fixer.cache
1 change: 0 additions & 1 deletion .php-cs-fixer.cache

This file was deleted.

10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Query API

Usage example:

```php
use Neo4j\QueryAPI\Neo4jQueryAPI;
use Neo4j\QueryAPI\Objects\Authentication;

$client = Neo4jQueryAPI::login('https://myaddress.com', Authentication::bearer('mytokken'))
```
13 changes: 13 additions & 0 deletions src/AuthenticateInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Neo4j\QueryAPI;

use Psr\Http\Message\RequestInterface;

interface AuthenticateInterface
{
/**
* Authenticates the request by returning a new instance of the request with the authentication information attached.
*/
public function authenticate(RequestInterface $request): RequestInterface;
}
31 changes: 31 additions & 0 deletions src/BasicAuthentication.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace Neo4j\QueryAPI;

use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;

class BasicAuthentication implements AuthenticateInterface
{
public function __construct(private string $username, private string $password)
{
$this->username = $username;
$this->password = $password;
}

public function authenticate(RequestInterface $request): RequestInterface
{
$authHeader = 'Basic ' . base64_encode($this->username . ':' . $this->password);
return $request->withHeader('Authorization', $authHeader);
}
public function getHeader(): string
{
return 'Basic ' . base64_encode($this->username . ':' . $this->password);
}

public function getType(): string
{
return 'Basic';
}

}
27 changes: 27 additions & 0 deletions src/BearerAuthentication.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Neo4j\QueryAPI;

use Psr\Http\Message\RequestInterface;

class BearerAuthentication implements AuthenticateInterface
{
public function __construct(private string $token)
{
}

public function authenticate(RequestInterface $request): RequestInterface
{
$authHeader = 'Bearer ' . $this->token;
return $request->withHeader('Authorization', $authHeader);
}
public function getHeader(): string
{
return 'Bearer ' . $this->token;
}

public function getType(): string
{
return 'Bearer';
}
}
Loading