mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
fix: connector creation
This commit is contained in:
@@ -7,6 +7,28 @@ use Ovh\Api;
|
||||
|
||||
readonly class OvhConnector implements ConnectorInterface
|
||||
{
|
||||
public const REQUIRED_ROUTES = [
|
||||
[
|
||||
'method' => 'GET',
|
||||
'path' => '/order/cart',
|
||||
], [
|
||||
'method' => 'GET',
|
||||
'path' => '/order/cart/*',
|
||||
],
|
||||
[
|
||||
'method' => 'POST',
|
||||
'path' => '/order/cart',
|
||||
],
|
||||
[
|
||||
'method' => 'POST',
|
||||
'path' => '/order/cart/*',
|
||||
],
|
||||
[
|
||||
'method' => 'DELETE',
|
||||
'path' => '/order/cart/*',
|
||||
],
|
||||
];
|
||||
|
||||
public function __construct(private array $authData)
|
||||
{
|
||||
}
|
||||
@@ -139,6 +161,23 @@ readonly class OvhConnector implements ConnectorInterface
|
||||
throw new \Exception("The status of these credentials is not valid ($status)");
|
||||
}
|
||||
|
||||
foreach (self::REQUIRED_ROUTES as $requiredRoute) {
|
||||
$ok = false;
|
||||
|
||||
foreach ($res['rules'] as $allowedRoute) {
|
||||
if (
|
||||
$requiredRoute['method'] === $allowedRoute['method']
|
||||
&& fnmatch($allowedRoute['path'], $requiredRoute['path'])
|
||||
) {
|
||||
$ok = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$ok) {
|
||||
throw new \Exception('The credentials provided do not have enough permissions to purchase a domain name.');
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'appKey' => $appKey,
|
||||
'appSecret' => $appSecret,
|
||||
|
||||
Reference in New Issue
Block a user