feat: update custom_rdap_servers.example.yaml

This commit is contained in:
Maël Gangloff
2024-11-02 16:11:41 +01:00
parent c7a50eed65
commit 79a5a1d35a
6 changed files with 48 additions and 44 deletions

View File

@@ -44,11 +44,13 @@
[ [ "ga" ], [ "https://rdap.nic.ga/" ] ], [ [ "ga" ], [ "https://rdap.nic.ga/" ] ],
[ [ "ht" ], [ "https://rdap.nic.ht/" ] ], [ [ "ht" ], [ "https://rdap.nic.ht/" ] ],
[ [ "in" ], [ "https://rdap.registry.in/" ] ], [ [ "in" ], [ "https://rdap.registry.in/" ] ],
[ [ "ke" ], [ "https://rdap.kenic.or.ke/" ] ],
[ [ "kn" ], [ "https://rdap.nic.kn/" ] ], [ [ "kn" ], [ "https://rdap.nic.kn/" ] ],
[ [ "li" ], [ "https://rdap.nic.li/" ] ], [ [ "li" ], [ "https://rdap.nic.li/" ] ],
[ [ "ml" ], [ "https://rdap.nic.ml/" ] ], [ [ "ml" ], [ "https://rdap.nic.ml/" ] ],
[ [ "mr" ], [ "https://rdap.nic.mr/" ] ], [ [ "mr" ], [ "https://rdap.nic.mr/" ] ],
[ [ "mz" ], [ "https://rdap.nic.mz/" ] ], [ [ "mz" ], [ "https://rdap.nic.mz/" ] ],
[ [ "ng" ], [ "https://rdap.nic.net.ng/" ] ],
[ [ "pr" ], [ "https://rdap.afilias-srs.net/rdap/pr/" ] ], [ [ "pr" ], [ "https://rdap.afilias-srs.net/rdap/pr/" ] ],
[ [ "sb" ], [ "https://rdap.nic.sb/" ] ], [ [ "sb" ], [ "https://rdap.nic.sb/" ] ],
[ [ "sn" ], [ "https://rdap.nic.sn/" ] ], [ [ "sn" ], [ "https://rdap.nic.sn/" ] ],

View File

@@ -79,7 +79,7 @@ abstract class AbstractProvider
/** /**
* @throws \Exception when the registrar denies the authentication * @throws \Exception when the registrar denies the authentication
*/ */
abstract public function assertAuthentication(): void; // TODO use dedicated exception type abstract protected function assertAuthentication(): void; // TODO use dedicated exception type
abstract public function orderDomain(Domain $domain, bool $dryRun): void; abstract public function orderDomain(Domain $domain, bool $dryRun): void;

View File

@@ -177,7 +177,9 @@ class AutodnsProvider extends AbstractProvider
} }
if ( if (
empty($username) || empty($password) !is_string($username) || empty($username)
|| !is_string($password) || empty($password)
|| true !== $authData['ownerConfirm']
) { ) {
throw new BadRequestHttpException('Bad authData schema'); throw new BadRequestHttpException('Bad authData schema');
} }
@@ -211,7 +213,7 @@ class AutodnsProvider extends AbstractProvider
/** /**
* @throws TransportExceptionInterface * @throws TransportExceptionInterface
*/ */
public function assertAuthentication(): void protected function assertAuthentication(): void
{ {
try { try {
$response = $this->client->request( $response = $this->client->request(

View File

@@ -108,7 +108,7 @@ class GandiProvider extends AbstractProvider
/** /**
* @throws TransportExceptionInterface * @throws TransportExceptionInterface
*/ */
public function assertAuthentication(): void protected function assertAuthentication(): void
{ {
$response = $this->client->request('GET', '/v5/organization/user-info', (new HttpOptions()) $response = $this->client->request('GET', '/v5/organization/user-info', (new HttpOptions())
->setAuthBearer($this->authData['token']) ->setAuthBearer($this->authData['token'])

View File

@@ -21,8 +21,11 @@ class NamecheapProvider extends AbstractProvider
public const SANDBOX_BASE_URL = 'https://api.sandbox.namecheap.com/xml.response'; public const SANDBOX_BASE_URL = 'https://api.sandbox.namecheap.com/xml.response';
public function __construct(CacheItemPoolInterface $cacheItemPool, private HttpClientInterface $client, private readonly string $outgoingIp) public function __construct(
{ CacheItemPoolInterface $cacheItemPool,
private readonly HttpClientInterface $client,
private readonly string $outgoingIp,
) {
parent::__construct($cacheItemPool); parent::__construct($cacheItemPool);
} }
@@ -32,11 +35,10 @@ class NamecheapProvider extends AbstractProvider
*/ */
public function orderDomain(Domain $domain, $dryRun): void public function orderDomain(Domain $domain, $dryRun): void
{ {
$addressesRes = $this->call('namecheap.users.address.getList', [], $dryRun); $addresses = $this->call('namecheap.users.address.getList', [], $dryRun)->AddressGetListResult->List;
$addresses = $addressesRes->AddressGetListResult->List;
if (count($addresses) < 1) { if (count($addresses) < 1) {
throw new \Exception('Namecheap account requires at least one address to purchase a domain'); throw new BadRequestHttpException('Namecheap account requires at least one address to purchase a domain');
} }
$addressId = (string) $addresses->attributes()['AddressId']; $addressId = (string) $addresses->attributes()['AddressId'];
@@ -54,10 +56,11 @@ class NamecheapProvider extends AbstractProvider
self::mergePrefixKeys('AuxBilling', $address, $domainAddresses); self::mergePrefixKeys('AuxBilling', $address, $domainAddresses);
$this->call('namecheap.domains.create', array_merge([ $this->call('namecheap.domains.create', array_merge([
'DomainName' => $domain->getLdhName(), 'DomainName' => $domain->getLdhName(), // Domain name to register
'Years' => 1, 'Years' => 1, // Number of years to register
'AddFreeWhoisguard' => 'yes', 'AddFreeWhoisguard' => 'yes', // Adds free domain privacy for the domain
'WGEnabled' => 'yes', 'WGEnabled' => 'yes', // Enables free domain privacy for the domain
'IsPremiumDomain' => 'False',
], $domainAddresses), $dryRun); ], $domainAddresses), $dryRun);
} }
@@ -100,13 +103,10 @@ class NamecheapProvider extends AbstractProvider
public function verifySpecificAuthData(array $authData): array public function verifySpecificAuthData(array $authData): array
{ {
$apiUser = $authData['ApiUser']; foreach (['ApiUser', 'ApiKey'] as $key) {
$apiKey = $authData['ApiKey']; if (empty($authData[$key]) || !is_string($authData[$key])) {
throw new BadRequestHttpException("Bad authData schema: missing or invalid '$key'");
if (!is_string($apiUser) || empty($apiUser) }
|| !is_string($apiKey) || empty($apiKey)
) {
throw new BadRequestHttpException('Bad authData schema');
} }
return [ return [
@@ -121,9 +121,13 @@ class NamecheapProvider extends AbstractProvider
* @throws RedirectionExceptionInterface * @throws RedirectionExceptionInterface
* @throws ClientExceptionInterface * @throws ClientExceptionInterface
*/ */
public function assertAuthentication(): void protected function assertAuthentication(): void
{ {
$this->call('namecheap.domains.gettldlist', [], false); $addresses = $this->call('namecheap.users.address.getList', [], false)->AddressGetListResult->List;
if (count($addresses) < 1) {
throw new BadRequestHttpException('Namecheap account requires at least one address to purchase a domain');
}
} }
/** /**

View File

@@ -133,34 +133,30 @@ class OvhProvider extends AbstractProvider
*/ */
public function verifySpecificAuthData(array $authData): array public function verifySpecificAuthData(array $authData): array
{ {
$appKey = $authData['appKey']; foreach ([
$appSecret = $authData['appSecret']; 'appKey',
$apiEndpoint = $authData['apiEndpoint']; 'appSecret',
$consumerKey = $authData['consumerKey']; 'apiEndpoint',
$ovhSubsidiary = $authData['ovhSubsidiary']; 'consumerKey',
$pricingMode = $authData['pricingMode']; 'ovhSubsidiary',
'pricingMode',
if (!is_string($appKey) || empty($appKey) ] as $key) {
|| !is_string($appSecret) || empty($appSecret) if (empty($authData[$key]) || !is_string($authData[$key])) {
|| !is_string($consumerKey) || empty($consumerKey) throw new BadRequestHttpException("Bad authData schema: missing or invalid '$key'");
|| !is_string($apiEndpoint) || empty($apiEndpoint) }
|| !is_string($ovhSubsidiary) || empty($ovhSubsidiary)
|| !is_string($pricingMode) || empty($pricingMode)
) {
throw new BadRequestHttpException('Bad authData schema');
} }
return [ return [
'appKey' => $appKey, 'appKey' => $authData['appKey'],
'appSecret' => $appSecret, 'appSecret' => $authData['appSecret'],
'apiEndpoint' => $apiEndpoint, 'apiEndpoint' => $authData['apiEndpoint'],
'consumerKey' => $consumerKey, 'consumerKey' => $authData['consumerKey'],
'ovhSubsidiary' => $ovhSubsidiary, 'ovhSubsidiary' => $authData['ovhSubsidiary'],
'pricingMode' => $pricingMode, 'pricingMode' => $authData['pricingMode'],
]; ];
} }
public function assertAuthentication(): void protected function assertAuthentication(): void
{ {
$conn = new Api( $conn = new Api(
$this->authData['appKey'], $this->authData['appKey'],