1
0
Fork 0
mirror of https://github.com/fernwerker/ownDynDNS.git synced 2025-07-13 15:15:42 +02:00

added option to pass netcup creds via url

This commit is contained in:
Nils Blume 2023-08-31 08:36:09 +02:00
parent 46d9f8f759
commit d974e5a886
4 changed files with 118 additions and 14 deletions

View file

@ -32,6 +32,7 @@ Parameter | Example | Explanation
`returnIp` | `true` / false | enables return of result if a record was changed
`allowCreate` | true/`false` | allows creation of entries if parameter `create=true` in URL
`restrictDomain` | true / `false` | allows admin to restrict the domain to update to a given value `domain` and/or `host`. See URL parameters for host parameter explanation
`allowNetcupCreds` | true / `false` | allows the user to pass netcup credentials directly via the URL. URL creds will be preferred if any still exist in .env file
* alternatively you can use .configure.sh to create your .env file for you (if you are on a *NIX system)
@ -60,6 +61,9 @@ txt | acme-challenge-text | the content to update an existing TXT record
force | true | ignore checking if the record needs to be updated, just do it anyways. Default: `false`
mode | * | `case B)` If domain is your registered domain "example.com". Possible values: `*` or `both`. Default: `@`
create | true | create all entries if none exist. e.g. will not create A if AAAA exists. Needs `allowCreate=true` in .env
customerId | 12345 | uses the URL provided credentials instead of the ones stored in .env. Needs `allowNetcupCreds=true` in .env
apiKey | 12345 | uses the URL provided credentials instead of the ones stored in .env. Needs `allowNetcupCreds=true` in .env
apiPassword | 12345 | uses the URL provided credentials instead of the ones stored in .env. Needs `allowNetcupCreds=true` in .env

View file

@ -55,6 +55,11 @@ final class Config
*/
private $allowCreate = false;
/**
* @var bool
*/
private $allowNetcupCreds = false;
/**
* @var bool
*/
@ -88,9 +93,16 @@ final class Config
return
!empty($this->username) &&
!empty($this->password) &&
(
(
!empty($this->apiKey) &&
!empty($this->apiPassword) &&
!empty($this->customerId) &&
!empty($this->customerId)
) ||
(
$this->isAllowNetcupCreds()
)
) &&
!empty($this->logFile);
}
@ -182,6 +194,14 @@ final class Config
return $this->restrictDomain;
}
/**
* @return bool
*/
public function isAllowNetcupCreds()
{
return $this->allowNetcupCreds;
}
/**
* @return string
*/

View file

@ -21,6 +21,21 @@ final class Handler
*/
private $payload;
/**
* @var int
*/
private $customerid;
/**
* @var string
*/
private $apikey;
/**
* @var string
*/
private $apipassword;
public function __construct(array $config, array $payload)
{
$this->config = new Config($config);
@ -54,6 +69,21 @@ final class Handler
}
}
if ($this->config->isAllowNetcupCreds()) {
if ($this->payload->isValidNetcupCreds()) {
if ($this->config->isDebug()) {
$this->doLog('received valid Netcup credentials');
}
}
$this->customerid = $this->payload->getCustomerId();
$this->apikey = $this->payload->getApiKey();
$this->apipassword = $this->payload->getApiPassword();
} else {
$this->customerid = $this->config->getCustomerId();
$this->apikey = $this->config->getApiKey();
$this->apipassword = $this->config->getApiPassword();
}
if (is_readable($this->config->getLogFile())) {
$this->log = json_decode(file_get_contents($this->config->getLogFile()), true);
} else {
@ -112,9 +142,9 @@ final class Handler
$dnsClient = new Soap\DomainWebserviceSoapClient();
$loginHandle = $dnsClient->login(
$this->config->getCustomerId(),
$this->config->getApiKey(),
$this->config->getApiPassword(),
$this->customerid,
$this->apikey,
$this->apipassword,
$clientRequestId
);
@ -139,8 +169,8 @@ final class Handler
$infoHandle = $dnsClient->infoDnsRecords(
$updateDomainName,
$this->config->getCustomerId(),
$this->config->getApiKey(),
$this->customerid,
$this->apikey,
$loginHandle->responsedata->apisessionid,
$clientRequestId
);
@ -231,8 +261,8 @@ final class Handler
$dnsClient->updateDnsRecords(
$updateDomainName,
$this->config->getCustomerId(),
$this->config->getApiKey(),
$this->customerid,
$this->apikey,
$loginHandle->responsedata->apisessionid,
$clientRequestId,
$newRecordSet
@ -248,8 +278,8 @@ final class Handler
$dnsClient->updateDnsRecords(
$updateDomainName,
$this->config->getCustomerId(),
$this->config->getApiKey(),
$this->customerid,
$this->apikey,
$loginHandle->responsedata->apisessionid,
$clientRequestId,
$recordSet
@ -261,8 +291,8 @@ final class Handler
}
$logoutHandle = $dnsClient->logout(
$this->config->getCustomerId(),
$this->config->getApiKey(),
$this->customerid,
$this->apikey,
$loginHandle->responsedata->apisessionid,
$clientRequestId
);

View file

@ -44,6 +44,21 @@ final class Payload
*/
private $host;
/**
* @var int
*/
private $customerId;
/**
* @var string
*/
private $apiKey;
/**
* @var string
*/
private $apiPassword;
/**
* @var bool
*/
@ -85,6 +100,41 @@ final class Payload
);
}
/**
* @return bool
*/
public function isValidNetcupCreds()
{
return
!empty($this->customerId) &&
!empty($this->apiKey) &&
!empty($this->apiPassword);
}
/**
* @return int
*/
public function getCustomerId()
{
return $this->customerId;
}
/**
* @return string
*/
public function getapiKey()
{
return $this->apiKey;
}
/**
* @return string
*/
public function getApiPassword()
{
return $this->apiPassword;
}
/**
* @return string
*/