Skip to content

Commit

Permalink
More handling of PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rjzondervan committed Dec 18, 2024
1 parent 5a6fe09 commit bf178e6
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 22 deletions.
1 change: 0 additions & 1 deletion lib/Controller/EndpointsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ public function page(): TemplateResponse
*/
public function index(ObjectService $objectService, SearchService $searchService): JSONResponse
{

$filters = $this->request->getParams();
$fieldsToSearch = ['name', 'description', 'endpoint'];

Expand Down
2 changes: 1 addition & 1 deletion lib/Db/EndpointMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public function findByPathRegex(string $path, string $method): array
$pattern = $endpoint->getEndpointRegex();

// Skip if no regex pattern is set
if (empty($pattern)) {
if (empty($pattern) === true) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Migration/Version1Date20241218122708.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
*/
$schema = $schemaClosure();

if($schema->hasTable(tableName: 'openconnector_consumers') === true) {
if ($schema->hasTable(tableName: 'openconnector_consumers') === true) {
$table = $schema->getTable(tableName: 'openconnector_consumers');
$table->dropColumn('authorization_configuration');
}
Expand Down
15 changes: 3 additions & 12 deletions lib/Service/AuthorizationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,23 +98,14 @@ private function checkHeaders(JWS $token): void
private function getJWK(string $publicKey, string $algorithm): JWKSet
{

if (
in_array(needle: $algorithm, haystack: self::HMAC_ALGORITHMS) === true
) {
if (in_array(needle: $algorithm, haystack: self::HMAC_ALGORITHMS) === true) {
return new JWKSet([
JWKFactory::createFromSecret(
secret: $publicKey,
additional_values: ['alg' => $algorithm, 'use' => 'sig'])
]);
} else if (
in_array(
needle: $algorithm,
haystack: self::PKCS1_ALGORITHMS
) === true
|| in_array(
needle: $algorithm,
haystack: self::PSS_ALGORITHMS
) === true
} else if (in_array(needle: $algorithm, haystack: self::PKCS1_ALGORITHMS) === true
|| in_array(needle: $algorithm, haystack: self::PSS_ALGORITHMS) === true
) {
$stamp = microtime() . getmypid();
$filename = "/var/tmp/publickey-$stamp";
Expand Down
14 changes: 7 additions & 7 deletions lib/Service/EndpointService.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function __construct(
* @param Endpoint $endpoint The endpoint configuration to handle
* @param IRequest $request The incoming request object
* @return JSONResponse Response containing the result
* @throws \Exception When endpoint configuration is invalid
* @throws Exception When endpoint configuration is invalid
*/
public function handleRequest(Endpoint $endpoint, IRequest $request, string $path): JSONResponse
{
Expand All @@ -76,9 +76,9 @@ public function handleRequest(Endpoint $endpoint, IRequest $request, string $pat
}

// Invalid endpoint configuration
throw new \Exception('Endpoint must specify either a schema or source connection');
throw new Exception('Endpoint must specify either a schema or source connection');

} catch (\Exception $e) {
} catch (Exception $e) {
$this->logger->error('Error handling endpoint request: ' . $e->getMessage());
return new JSONResponse(
['error' => $e->getMessage()],
Expand Down Expand Up @@ -145,8 +145,10 @@ private function getObjects(
if (isset($pathParams['id']) === true && $pathParams['id'] === end($pathParams)) {
return $mapper->find($pathParams['id']);
} else if (isset($pathParams['id']) === true) {

// Set the array pointer to the location of the id, so we can fetch the parameters further down the line in order.
while (prev($pathParams) !== $pathParams['id']) {
};
}

$property = next($pathParams);

Expand Down Expand Up @@ -179,7 +181,6 @@ private function getObjects(
$parameters['page'] = $result['page'] + 1;
$parameters['_path'] = implode('/', $pathParams);


$returnArray['next'] = $this->urlGenerator->getAbsoluteURL(
$this->urlGenerator->linkToRoute(
routeName: 'openconnector.endpoints.handlepath',
Expand Down Expand Up @@ -244,7 +245,7 @@ private function handleSchemaRequest(Endpoint $endpoint, IRequest $request, stri
'DELETE' => new JSONResponse(
$mapper->delete($request->getParams())
),
default => throw new \Exception('Unsupported HTTP method')
default => throw new Exception('Unsupported HTTP method')
};
}

Expand Down Expand Up @@ -307,7 +308,6 @@ private function getHeaders(array $server, bool $proxyHeaders = false): array
*/
private function handleSourceRequest(Endpoint $endpoint, IRequest $request): JSONResponse
{

$headers = $this->getHeaders($request->server);

// Proxy the request to the source via CallService
Expand Down

0 comments on commit bf178e6

Please sign in to comment.