Skip to content

Commit b92625e

Browse files
committed
alidns: upgrade libdns to v 1.0.6-beta.1 and introduce the security_token
1 parent 1af6abb commit b92625e

4 files changed

Lines changed: 936 additions & 154 deletions

File tree

README.md

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Alibaba Cloud DNS (AliDNS) module for Caddy
22
===========================
33

4-
This package contains a DNS provider module for [Caddy](https://github.com/caddyserver/caddy). It can be used to manage DNS records with Alibaba Cloud (as is Aliyun or ALIYUN) accounts.
4+
This package contains a DNS provider module for [Caddy](https://github.com/caddyserver/caddy). It can be used to manage DNS records with Alibaba Cloud (as is Aliyun,aliyun or ALIYUN) accounts.
55

66
## Caddy module name
77

@@ -19,9 +19,9 @@ To use this module for the ACME DNS challenge, [configure the ACME issuer in you
1919
"challenges": {
2020
"dns": {
2121
"provider": {
22-
"name": "alidns",
23-
"access_key_id":"YOUR_ALIYUN_ACCESS_KEY_ID",
24-
"access_key_secret":"YOUR_ALIYUN_ACCESS_KEY_SECRET"
22+
"name": "alidns",
23+
"access_key_id":"YOUR_ALIYUN_ACCESS_KEY_ID",
24+
"access_key_secret":"YOUR_ALIYUN_ACCESS_KEY_SECRET"
2525
}
2626
}
2727
}
@@ -50,8 +50,49 @@ tls {
5050
}
5151
```
5252

53-
You can replace `{env.ALIYUN_ACCESS_KEY_ID}`,`{env.ALIYUN_ACCESS_KEY_SECRET}` with the actual auth token in the `""` if you prefer to put it directly in your config instead of an environment variable.
53+
If you have `SecurityToken` for aliyun's STS authorization you can configure like:
5454

55+
```json
56+
{
57+
"module": "acme",
58+
"challenges": {
59+
"dns": {
60+
"provider": {
61+
"name": "alidns",
62+
"access_key_id":"YOUR_ALIYUN_ACCESS_KEY_ID",
63+
"access_key_secret":"YOUR_ALIYUN_ACCESS_KEY_SECRET",
64+
"security_token": "YOU_ALIYUN_SECURITY_TOKEN"
65+
}
66+
}
67+
}
68+
}
69+
```
70+
71+
or with the Caddyfile:
72+
73+
```
74+
# globally
75+
76+
acme_dns alidns {
77+
access_key_id {env.ALIYUN_ACCESS_KEY_ID}
78+
access_key_secret {env.ALIYUN_ACCESS_KEY_SECRET}
79+
security_token {env.ALIYUN_SECURITY_TOKEN}
80+
}
81+
```
82+
83+
```
84+
# one site
85+
86+
tls {
87+
dns alidns {
88+
access_key_id {env.ALIYUN_ACCESS_KEY_ID}
89+
access_key_secret {env.ALIYUN_ACCESS_KEY_SECRET}
90+
security_token {env.ALIYUN_SECURITY_TOKEN}
91+
}
92+
}
93+
```
94+
95+
You can replace `{env.ALIYUN_ACCESS_KEY_ID}`,`{env.ALIYUN_ACCESS_KEY_SECRET}`,`{env.ALIYUN_SECURITY_TOKEN}` with the actual auth token in the `""` if you prefer to put it directly in your config instead of an environment variable.
5596

5697
## Authenticating
5798

alidns.go

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,20 @@ func (Provider) CaddyModule() caddy.ModuleInfo {
2525
// Implements caddy.Provisioner.
2626
func (p *Provider) Provision(ctx caddy.Context) error {
2727
repl := caddy.NewReplacer()
28-
p.Provider.AccKeyID = repl.ReplaceAll(p.Provider.AccKeyID, "")
29-
p.Provider.AccKeySecret = repl.ReplaceAll(p.Provider.AccKeySecret, "")
28+
p.Provider.AccessKeyID = repl.ReplaceAll(p.Provider.AccessKeyID, "")
29+
p.Provider.AccessKeySecret = repl.ReplaceAll(p.Provider.AccessKeySecret, "")
30+
p.Provider.SecurityToken = repl.ReplaceAll(p.SecurityToken, "")
3031
return nil
3132
}
3233

3334
// UnmarshalCaddyfile sets up the DNS provider from Caddyfile tokens. Syntax:
3435
//
35-
// alidns {
36-
// access_key_id "<access_key_id>"
37-
// access_key_secret "<access_key_secret>"
38-
// }
39-
//
36+
// alidns {
37+
// access_key_id "<access_key_id>"
38+
// access_key_secret "<access_key_secret>"
39+
// region_id "<region_id,defaults to 'cn-hangzhou' if empty>"
40+
// security_token "<security_token, if you use the STS authorization it's required by aliyun>"
41+
// }
4042
func (p *Provider) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
4143
for d.Next() {
4244
if d.NextArg() {
@@ -46,14 +48,28 @@ func (p *Provider) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
4648
switch d.Val() {
4749
case "access_key_id":
4850
if d.NextArg() {
49-
p.Provider.AccKeyID = d.Val()
51+
p.Provider.AccessKeyID = d.Val()
5052
}
5153
if d.NextArg() {
5254
return d.ArgErr()
5355
}
5456
case "access_key_secret":
5557
if d.NextArg() {
56-
p.Provider.AccKeySecret = d.Val()
58+
p.Provider.AccessKeySecret = d.Val()
59+
}
60+
if d.NextArg() {
61+
return d.ArgErr()
62+
}
63+
case "region_id":
64+
if d.NextArg() {
65+
p.Provider.RegionID = d.Val()
66+
}
67+
if d.NextArg() {
68+
return d.ArgErr()
69+
}
70+
case "security_token":
71+
if d.NextArg() {
72+
p.Provider.SecurityToken = d.Val()
5773
}
5874
if d.NextArg() {
5975
return d.ArgErr()
@@ -63,7 +79,7 @@ func (p *Provider) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
6379
}
6480
}
6581
}
66-
if p.AccKeyID == "" || p.AccKeySecret == "" {
82+
if p.AccessKeyID == "" || p.AccessKeySecret == "" {
6783
return d.Err("AccessKeyID or AccessKeySecret is empty")
6884
}
6985
return nil

go.mod

Lines changed: 3 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,8 @@
11
module github.com/caddy-dns/alidns
22

3-
go 1.22.3
3+
go 1.16
44

55
require (
6-
github.com/caddyserver/caddy/v2 v2.9.1
7-
github.com/libdns/alidns v1.0.5-libdns.v1.beta1
8-
)
9-
10-
require (
11-
github.com/beorn7/perks v1.0.1 // indirect
12-
github.com/caddyserver/certmagic v0.21.6 // indirect
13-
github.com/caddyserver/zerossl v0.1.3 // indirect
14-
github.com/cespare/xxhash/v2 v2.3.0 // indirect
15-
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
16-
github.com/francoispqt/gojay v1.2.13 // indirect
17-
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
18-
github.com/google/pprof v0.0.0-20231212022811-ec68065c825e // indirect
19-
github.com/google/uuid v1.6.0 // indirect
20-
github.com/klauspost/cpuid/v2 v2.2.9 // indirect
21-
github.com/libdns/libdns v1.0.0-beta.1 // indirect
22-
github.com/mholt/acmez/v3 v3.0.0 // indirect
23-
github.com/miekg/dns v1.1.62 // indirect
24-
github.com/onsi/ginkgo/v2 v2.13.2 // indirect
25-
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
26-
github.com/prometheus/client_golang v1.19.1 // indirect
27-
github.com/prometheus/client_model v0.6.0 // indirect
28-
github.com/prometheus/common v0.48.0 // indirect
29-
github.com/prometheus/procfs v0.12.0 // indirect
30-
github.com/quic-go/qpack v0.5.1 // indirect
31-
github.com/quic-go/quic-go v0.48.2 // indirect
32-
github.com/zeebo/assert v1.3.0 // indirect
33-
github.com/zeebo/blake3 v0.2.4 // indirect
34-
go.uber.org/mock v0.4.0 // indirect
35-
go.uber.org/multierr v1.11.0 // indirect
36-
go.uber.org/zap v1.27.0 // indirect
37-
go.uber.org/zap/exp v0.3.0 // indirect
38-
golang.org/x/crypto v0.31.0 // indirect
39-
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
40-
golang.org/x/mod v0.18.0 // indirect
41-
golang.org/x/net v0.33.0 // indirect
42-
golang.org/x/sync v0.10.0 // indirect
43-
golang.org/x/sys v0.28.0 // indirect
44-
golang.org/x/term v0.27.0 // indirect
45-
golang.org/x/text v0.21.0 // indirect
46-
golang.org/x/time v0.7.0 // indirect
47-
golang.org/x/tools v0.22.0 // indirect
48-
google.golang.org/protobuf v1.35.1 // indirect
6+
github.com/caddyserver/caddy/v2 v2.4.1
7+
github.com/libdns/alidns v1.0.6-beta.1
498
)

0 commit comments

Comments
 (0)