caddy/modules/caddytls
Will Norris db3e19b7b5
caddytls: fix permission requirement with AutomationPolicy (#6328)
Certificate automation has permission modules that are designed to
prevent inappropriate issuance of unbounded or wildcard certificates.
When an explicit cert manager is used, no additional permission should
be necessary. For example, this should be a valid caddyfile:

    https:// {
      tls {
        get_certificate tailscale
      }
      respond OK
    }

This is accomplished when provisioning an AutomationPolicy by tracking
whether there were explicit managers configured directly on the policy
(in the ManagersRaw field). Only when a number of potentially unsafe
conditions are present AND no explicit cert managers are configured is
an error returned.

The problem arises from the fact that ctx.LoadModule deletes the raw
bytes after loading in order to save memory. The first time an
AutomationPolicy is provisioned, the ManagersRaw field is populated, and
everything is fine.

An AutomationPolicy with no subjects is treated as a special "catch-all"
policy. App.createAutomationPolicies ensures that this catch-all policy
has an ACME issuer, and then calls its Provision method again because it
may have changed. This second time Provision is called, ManagesRaw is no
longer populated, and the permission check fails because it appears as
though the policy has no explicit managers.

Address this by storing a new boolean on AutomationPolicy recording
whether it had explicit cert managers configured on it.

Also fix an inverted boolean check on this value when setting
failClosed.

Updates #6060
Updates #6229
Updates #6327

Signed-off-by: Will Norris <will@tailscale.com>
2024-05-20 09:48:59 -06:00
..
distributedstek ci: use gci linter (#5708) 2023-08-14 09:41:15 -06:00
standardstek all: Recover from panics in goroutines 2020-05-12 11:36:20 -06:00
acmeissuer.go run golangci-lint run --fix --fast (#6270) 2024-04-24 15:17:23 -06:00
automation.go caddytls: fix permission requirement with AutomationPolicy (#6328) 2024-05-20 09:48:59 -06:00
capools.go reverseproxy: Pointer to struct when loading modules; remove LazyCertPool (#6307) 2024-05-08 19:13:37 -06:00
capools_test.go Fix typos (#6311) 2024-05-10 08:08:54 -06:00
certmanagers.go caddytls: remove ClientHelloSNICtxKey (#6326) 2024-05-18 22:47:46 -04:00
certselection.go chore: Appease gosec linter (#5777) 2023-08-23 20:47:54 -06:00
cf.go tls: Add X25519Kyber768Draft00 PQ "curve" behind build tag (#5852) 2023-10-11 13:45:37 -06:00
connpolicy.go Fix typos (#6311) 2024-05-10 08:08:54 -06:00
connpolicy_test.go modules: fix some typo in conments (#6206) 2024-03-30 02:45:42 +00:00
fileloader.go tls: accept placeholders in string values of certificate loaders (#5963) 2023-12-04 09:23:15 -07:00
folderloader.go tls: accept placeholders in string values of certificate loaders (#5963) 2023-12-04 09:23:15 -07:00
internalissuer.go Fix typos (#6311) 2024-05-10 08:08:54 -06:00
leaffileloader.go caddytls: clientauth: leaf verifier: make trusted leaf certs source pluggable (#6050) 2024-03-05 14:55:37 -07:00
leaffileloader_test.go caddytls: clientauth: leaf verifier: make trusted leaf certs source pluggable (#6050) 2024-03-05 14:55:37 -07:00
leaffolderloader.go caddytls: clientauth: leaf verifier: make trusted leaf certs source pluggable (#6050) 2024-03-05 14:55:37 -07:00
leaffolderloader_test.go caddytls: clientauth: leaf verifier: make trusted leaf certs source pluggable (#6050) 2024-03-05 14:55:37 -07:00
leafpemloader.go caddytls: clientauth: leaf verifier: make trusted leaf certs source pluggable (#6050) 2024-03-05 14:55:37 -07:00
leafpemloader_test.go caddytls: clientauth: leaf verifier: make trusted leaf certs source pluggable (#6050) 2024-03-05 14:55:37 -07:00
leafstorageloader.go caddytls: clientauth: leaf verifier: make trusted leaf certs source pluggable (#6050) 2024-03-05 14:55:37 -07:00
matchers.go Fix typos (#6311) 2024-05-10 08:08:54 -06:00
matchers_test.go connection policy: add local_ip matcher (#6074) 2024-04-15 21:13:24 +03:00
ondemand.go caddytls: Add Caddyfile support for on-demand permission module (close #6260) 2024-04-22 15:47:09 -06:00
pemloader.go tls: accept placeholders in string values of certificate loaders (#5963) 2023-12-04 09:23:15 -07:00
sessiontickets.go all: Recover from panics in goroutines 2020-05-12 11:36:20 -06:00
storageloader.go tls: accept placeholders in string values of certificate loaders (#5963) 2023-12-04 09:23:15 -07:00
tls.go caddytls: Evict internal certs from cache based on issuer (#6266) 2024-04-30 16:15:54 -06:00
values.go go.mod: Upgrade some dependencies 2020-12-08 14:06:52 -07:00
zerosslissuer.go caddytls: Upgrade ACMEz to v2; support ZeroSSL API; various fixes (#6229) 2024-04-13 21:31:43 -04:00