mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-17 17:55:42 +00:00
fix: connector creation
This commit is contained in:
parent
6f3c780e42
commit
da1ae4cb8e
@ -7,7 +7,7 @@ export const helpGetTokenLink = (provider?: string) => {
|
||||
switch (provider) {
|
||||
case ConnectorProvider.OVH:
|
||||
return <Typography.Link target='_blank'
|
||||
href="https://api.ovh.com/createToken/index.cgi?GET=/order/cart/*&POST=/order/cart&POST=/order/cart/*&DELETE=/order/cart/*">
|
||||
href="https://api.ovh.com/createToken/index.cgi?GET=/order/cart&GET=/order/cart/*&POST=/order/cart&POST=/order/cart/*&DELETE=/order/cart/*">
|
||||
{t`Retrieve a set of tokens from your customer account on the Provider's website`}
|
||||
</Typography.Link>
|
||||
default:
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -81,6 +81,7 @@ class ConnectorController extends AbstractController
|
||||
'username' => $user->getUserIdentifier(),
|
||||
]);
|
||||
|
||||
$connector->setCreatedAt(new \DateTimeImmutable('now'));
|
||||
$this->em->persist($connector);
|
||||
$this->em->flush();
|
||||
|
||||
|
||||
@ -30,7 +30,6 @@ use Symfony\Component\Uid\Uuid;
|
||||
new Post(
|
||||
routeName: 'connector_create',
|
||||
normalizationContext: ['groups' => ['connector:create', 'connector:list']], denormalizationContext: ['groups' => 'connector:create'],
|
||||
security: 'object.user == user',
|
||||
name: 'create'
|
||||
),
|
||||
new Delete(),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user