Gandi: Add support for personal access tokens.
This commit is contained in:
parent
5b104ad116
commit
65e77256f7
1 changed files with 13 additions and 9 deletions
22
ddclient.in
22
ddclient.in
|
|
@ -7451,24 +7451,25 @@ Description of Gandi's LiveDNS API can be found at:
|
||||||
https://api.gandi.net/docs/livedns/
|
https://api.gandi.net/docs/livedns/
|
||||||
|
|
||||||
Available configuration variables:
|
Available configuration variables:
|
||||||
* password: The Gandi API key. If you don’t have one yet, you can generate
|
* password: The Gandi API key or personal access token. If you don’t have one
|
||||||
your production API key from the API Key Page (in the Security section).
|
yet, you can generate your keys and personal access tokens from
|
||||||
|
https://accounts.gandi.net. To use a token, prefix the password with 'pat:'.
|
||||||
Required.
|
Required.
|
||||||
* zone: The DNS zone to be updated. Required.
|
* zone: The DNS zone to be updated. Required.
|
||||||
* ttl: The time-to-live value associated with the updated DNS record.
|
* ttl: The time-to-live value associated with the updated DNS record.
|
||||||
Optional; uses Gandi's default (10800) if unset.
|
Optional; uses Gandi's default (10800) if unset.
|
||||||
|
|
||||||
Example ${program}.conf file entries:
|
Example ${program}.conf file entries:
|
||||||
## Single host update.
|
## Single host update with API key.
|
||||||
protocol=gandi
|
protocol=gandi
|
||||||
zone=example.com
|
zone=example.com
|
||||||
password=my-gandi-api-key
|
password=my-gandi-api-key
|
||||||
host.example.com
|
host.example.com
|
||||||
|
|
||||||
## Multiple host update.
|
## Multiple host update with Bearer token.
|
||||||
protocol=gandi
|
protocol=gandi
|
||||||
zone=example.com
|
zone=example.com
|
||||||
password=my-gandi-api-key
|
password=pat:my-personal-access-token
|
||||||
ttl=3600 # optional
|
ttl=3600 # optional
|
||||||
hosta.example.com,hostb.sub.example.com
|
hosta.example.com,hostb.sub.example.com
|
||||||
EoEXAMPLE
|
EoEXAMPLE
|
||||||
|
|
@ -7492,10 +7493,13 @@ sub nic_gandi_update {
|
||||||
|
|
||||||
my $headers;
|
my $headers;
|
||||||
$headers = "Content-Type: application/json\n";
|
$headers = "Content-Type: application/json\n";
|
||||||
$headers .= "Authorization: Apikey $config{$h}{'password'}\n";
|
my $password = $config{$h}{'password'};
|
||||||
|
# If password starts with 'pat:', use Bearer authentication.
|
||||||
|
if ($password =~ s/^pat://) {
|
||||||
|
$headers .= "Authorization: Bearer $password\n";
|
||||||
|
} else {
|
||||||
|
$headers .= "Authorization: Apikey $password\n";
|
||||||
|
}
|
||||||
my $rrset_type = $ipv eq 'ipv6' ? 'AAAA' : 'A';
|
my $rrset_type = $ipv eq 'ipv6' ? 'AAAA' : 'A';
|
||||||
my $url;
|
my $url;
|
||||||
$url = "https://$config{$h}{'server'}$config{$h}{'script'}";
|
$url = "https://$config{$h}{'server'}$config{$h}{'script'}";
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue