Skip to content

Commit d7564d6

Browse files
caddytls: Drop rate_limit and burst, has been deprecated (#6611)
1 parent 88fd5f3 commit d7564d6

File tree

7 files changed

+7
-89
lines changed

7 files changed

+7
-89
lines changed

caddyconfig/httpcaddyfile/options.go

+2-28
Original file line numberDiff line numberDiff line change
@@ -394,36 +394,10 @@ func parseOptOnDemand(d *caddyfile.Dispenser, _ any) (any, error) {
394394
ond.PermissionRaw = caddyconfig.JSONModuleObject(perm, "module", modName, nil)
395395

396396
case "interval":
397-
if !d.NextArg() {
398-
return nil, d.ArgErr()
399-
}
400-
dur, err := caddy.ParseDuration(d.Val())
401-
if err != nil {
402-
return nil, err
403-
}
404-
if ond == nil {
405-
ond = new(caddytls.OnDemandConfig)
406-
}
407-
if ond.RateLimit == nil {
408-
ond.RateLimit = new(caddytls.RateLimit)
409-
}
410-
ond.RateLimit.Interval = caddy.Duration(dur)
397+
return nil, d.Errf("the on_demand_tls 'interval' option is no longer supported, remove it from your config")
411398

412399
case "burst":
413-
if !d.NextArg() {
414-
return nil, d.ArgErr()
415-
}
416-
burst, err := strconv.Atoi(d.Val())
417-
if err != nil {
418-
return nil, err
419-
}
420-
if ond == nil {
421-
ond = new(caddytls.OnDemandConfig)
422-
}
423-
if ond.RateLimit == nil {
424-
ond.RateLimit = new(caddytls.RateLimit)
425-
}
426-
ond.RateLimit.Burst = burst
400+
return nil, d.Errf("the on_demand_tls 'burst' option is no longer supported, remove it from your config")
427401

428402
default:
429403
return nil, d.Errf("unrecognized parameter '%s'", d.Val())

caddytest/integration/caddyfile_adapt/global_options.caddyfiletest

-6
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
admin off
1818
on_demand_tls {
1919
ask https://example.com
20-
interval 30s
21-
burst 20
2220
}
2321
local_certs
2422
key_type ed25519
@@ -72,10 +70,6 @@
7270
"permission": {
7371
"endpoint": "https://example.com",
7472
"module": "http"
75-
},
76-
"rate_limit": {
77-
"interval": 30000000000,
78-
"burst": 20
7973
}
8074
}
8175
},

caddytest/integration/caddyfile_adapt/global_options_acme.caddyfiletest

-6
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
admin off
1818
on_demand_tls {
1919
ask https://example.com
20-
interval 30s
21-
burst 20
2220
}
2321
storage_clean_interval 7d
2422
renew_interval 1d
@@ -89,10 +87,6 @@
8987
"permission": {
9088
"endpoint": "https://example.com",
9189
"module": "http"
92-
},
93-
"rate_limit": {
94-
"interval": 30000000000,
95-
"burst": 20
9690
}
9791
},
9892
"ocsp_interval": 172800000000000,

caddytest/integration/caddyfile_adapt/global_options_admin.caddyfiletest

-6
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
}
1717
on_demand_tls {
1818
ask https://example.com
19-
interval 30s
20-
burst 20
2119
}
2220
local_certs
2321
key_type ed25519
@@ -74,10 +72,6 @@
7472
"permission": {
7573
"endpoint": "https://example.com",
7674
"module": "http"
77-
},
78-
"rate_limit": {
79-
"interval": 30000000000,
80-
"burst": 20
8175
}
8276
}
8377
}

modules/caddytls/automation.go

-6
Original file line numberDiff line numberDiff line change
@@ -322,12 +322,6 @@ func (ap *AutomationPolicy) Provision(tlsApp *TLS) error {
322322
return err
323323
}
324324

325-
// check the rate limiter last because
326-
// doing so makes a reservation
327-
if !onDemandRateLimiter.Allow() {
328-
return fmt.Errorf("on-demand rate limit exceeded")
329-
}
330-
331325
return nil
332326
},
333327
Managers: ap.Managers,

modules/caddytls/ondemand.go

+5-26
Original file line numberDiff line numberDiff line change
@@ -38,38 +38,18 @@ func init() {
3838

3939
// OnDemandConfig configures on-demand TLS, for obtaining
4040
// needed certificates at handshake-time. Because this
41-
// feature can easily be abused, you should use this to
42-
// establish rate limits and/or an internal endpoint that
43-
// Caddy can "ask" if it should be allowed to manage
44-
// certificates for a given hostname.
41+
// feature can easily be abused, Caddy must ask permission
42+
// to your application whether a particular domain is allowed
43+
// to have a certificate issued for it.
4544
type OnDemandConfig struct {
46-
// DEPRECATED. WILL BE REMOVED SOON. Use 'permission' instead.
45+
// DEPRECATED. WILL BE REMOVED SOON. Use 'permission' instead with the `http` module.
4746
Ask string `json:"ask,omitempty"`
4847

4948
// REQUIRED. A module that will determine whether a
5049
// certificate is allowed to be loaded from storage
5150
// or obtained from an issuer on demand.
5251
PermissionRaw json.RawMessage `json:"permission,omitempty" caddy:"namespace=tls.permission inline_key=module"`
5352
permission OnDemandPermission
54-
55-
// DEPRECATED. An optional rate limit to throttle
56-
// the checking of storage and the issuance of
57-
// certificates from handshakes if not already in
58-
// storage. WILL BE REMOVED IN A FUTURE RELEASE.
59-
RateLimit *RateLimit `json:"rate_limit,omitempty"`
60-
}
61-
62-
// DEPRECATED. WILL LIKELY BE REMOVED SOON.
63-
// Instead of using this rate limiter, use a proper tool such as a
64-
// level 3 or 4 firewall and/or a permission module to apply rate limits.
65-
type RateLimit struct {
66-
// A duration value. Storage may be checked and a certificate may be
67-
// obtained 'burst' times during this interval.
68-
Interval caddy.Duration `json:"interval,omitempty"`
69-
70-
// How many times during an interval storage can be checked or a
71-
// certificate can be obtained.
72-
Burst int `json:"burst,omitempty"`
7353
}
7454

7555
// OnDemandPermission is a type that can give permission for
@@ -195,8 +175,7 @@ var ErrPermissionDenied = errors.New("certificate not allowed by permission modu
195175

196176
// These perpetual values are used for on-demand TLS.
197177
var (
198-
onDemandRateLimiter = certmagic.NewRateLimiter(0, 0)
199-
onDemandAskClient = &http.Client{
178+
onDemandAskClient = &http.Client{
200179
Timeout: 10 * time.Second,
201180
CheckRedirect: func(req *http.Request, via []*http.Request) error {
202181
return fmt.Errorf("following http redirects is not allowed")

modules/caddytls/tls.go

-11
Original file line numberDiff line numberDiff line change
@@ -188,17 +188,6 @@ func (t *TLS) Provision(ctx caddy.Context) error {
188188
t.Automation.OnDemand.permission = val.(OnDemandPermission)
189189
}
190190

191-
// on-demand rate limiting (TODO: deprecated, and should be removed later; rate limiting is ineffective now that permission modules are required)
192-
if t.Automation != nil && t.Automation.OnDemand != nil && t.Automation.OnDemand.RateLimit != nil {
193-
t.logger.Warn("DEPRECATED: on_demand.rate_limit will be removed in a future release; use permission modules or external certificate managers instead")
194-
onDemandRateLimiter.SetMaxEvents(t.Automation.OnDemand.RateLimit.Burst)
195-
onDemandRateLimiter.SetWindow(time.Duration(t.Automation.OnDemand.RateLimit.Interval))
196-
} else {
197-
// remove any existing rate limiter
198-
onDemandRateLimiter.SetWindow(0)
199-
onDemandRateLimiter.SetMaxEvents(0)
200-
}
201-
202191
// run replacer on ask URL (for environment variables) -- return errors to prevent surprises (#5036)
203192
if t.Automation != nil && t.Automation.OnDemand != nil && t.Automation.OnDemand.Ask != "" {
204193
t.Automation.OnDemand.Ask, err = repl.ReplaceOrErr(t.Automation.OnDemand.Ask, true, true)

0 commit comments

Comments
 (0)