mirror of
https://github.com/fernwerker/ownDynDNS.git
synced 2025-07-13 23:15:43 +02:00
added option to pass netcup creds via url
This commit is contained in:
parent
46d9f8f759
commit
d974e5a886
4 changed files with 118 additions and 14 deletions
|
@ -32,6 +32,7 @@ Parameter | Example | Explanation
|
||||||
`returnIp` | `true` / false | enables return of result if a record was changed
|
`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
|
`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
|
`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)
|
* 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`
|
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: `@`
|
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
|
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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,11 @@ final class Config
|
||||||
*/
|
*/
|
||||||
private $allowCreate = false;
|
private $allowCreate = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
private $allowNetcupCreds = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
|
@ -88,9 +93,16 @@ final class Config
|
||||||
return
|
return
|
||||||
!empty($this->username) &&
|
!empty($this->username) &&
|
||||||
!empty($this->password) &&
|
!empty($this->password) &&
|
||||||
!empty($this->apiKey) &&
|
(
|
||||||
!empty($this->apiPassword) &&
|
(
|
||||||
!empty($this->customerId) &&
|
!empty($this->apiKey) &&
|
||||||
|
!empty($this->apiPassword) &&
|
||||||
|
!empty($this->customerId)
|
||||||
|
) ||
|
||||||
|
(
|
||||||
|
$this->isAllowNetcupCreds()
|
||||||
|
)
|
||||||
|
) &&
|
||||||
!empty($this->logFile);
|
!empty($this->logFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,6 +194,14 @@ final class Config
|
||||||
return $this->restrictDomain;
|
return $this->restrictDomain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isAllowNetcupCreds()
|
||||||
|
{
|
||||||
|
return $this->allowNetcupCreds;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -21,6 +21,21 @@ final class Handler
|
||||||
*/
|
*/
|
||||||
private $payload;
|
private $payload;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $customerid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $apikey;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $apipassword;
|
||||||
|
|
||||||
public function __construct(array $config, array $payload)
|
public function __construct(array $config, array $payload)
|
||||||
{
|
{
|
||||||
$this->config = new Config($config);
|
$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())) {
|
if (is_readable($this->config->getLogFile())) {
|
||||||
$this->log = json_decode(file_get_contents($this->config->getLogFile()), true);
|
$this->log = json_decode(file_get_contents($this->config->getLogFile()), true);
|
||||||
} else {
|
} else {
|
||||||
|
@ -112,9 +142,9 @@ final class Handler
|
||||||
$dnsClient = new Soap\DomainWebserviceSoapClient();
|
$dnsClient = new Soap\DomainWebserviceSoapClient();
|
||||||
|
|
||||||
$loginHandle = $dnsClient->login(
|
$loginHandle = $dnsClient->login(
|
||||||
$this->config->getCustomerId(),
|
$this->customerid,
|
||||||
$this->config->getApiKey(),
|
$this->apikey,
|
||||||
$this->config->getApiPassword(),
|
$this->apipassword,
|
||||||
$clientRequestId
|
$clientRequestId
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -139,8 +169,8 @@ final class Handler
|
||||||
|
|
||||||
$infoHandle = $dnsClient->infoDnsRecords(
|
$infoHandle = $dnsClient->infoDnsRecords(
|
||||||
$updateDomainName,
|
$updateDomainName,
|
||||||
$this->config->getCustomerId(),
|
$this->customerid,
|
||||||
$this->config->getApiKey(),
|
$this->apikey,
|
||||||
$loginHandle->responsedata->apisessionid,
|
$loginHandle->responsedata->apisessionid,
|
||||||
$clientRequestId
|
$clientRequestId
|
||||||
);
|
);
|
||||||
|
@ -231,8 +261,8 @@ final class Handler
|
||||||
|
|
||||||
$dnsClient->updateDnsRecords(
|
$dnsClient->updateDnsRecords(
|
||||||
$updateDomainName,
|
$updateDomainName,
|
||||||
$this->config->getCustomerId(),
|
$this->customerid,
|
||||||
$this->config->getApiKey(),
|
$this->apikey,
|
||||||
$loginHandle->responsedata->apisessionid,
|
$loginHandle->responsedata->apisessionid,
|
||||||
$clientRequestId,
|
$clientRequestId,
|
||||||
$newRecordSet
|
$newRecordSet
|
||||||
|
@ -248,8 +278,8 @@ final class Handler
|
||||||
|
|
||||||
$dnsClient->updateDnsRecords(
|
$dnsClient->updateDnsRecords(
|
||||||
$updateDomainName,
|
$updateDomainName,
|
||||||
$this->config->getCustomerId(),
|
$this->customerid,
|
||||||
$this->config->getApiKey(),
|
$this->apikey,
|
||||||
$loginHandle->responsedata->apisessionid,
|
$loginHandle->responsedata->apisessionid,
|
||||||
$clientRequestId,
|
$clientRequestId,
|
||||||
$recordSet
|
$recordSet
|
||||||
|
@ -261,8 +291,8 @@ final class Handler
|
||||||
}
|
}
|
||||||
|
|
||||||
$logoutHandle = $dnsClient->logout(
|
$logoutHandle = $dnsClient->logout(
|
||||||
$this->config->getCustomerId(),
|
$this->customerid,
|
||||||
$this->config->getApiKey(),
|
$this->apikey,
|
||||||
$loginHandle->responsedata->apisessionid,
|
$loginHandle->responsedata->apisessionid,
|
||||||
$clientRequestId
|
$clientRequestId
|
||||||
);
|
);
|
||||||
|
|
|
@ -44,6 +44,21 @@ final class Payload
|
||||||
*/
|
*/
|
||||||
private $host;
|
private $host;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $customerId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $apiKey;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $apiPassword;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var bool
|
* @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
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue