From a285fe41296cf786b21f637ebe9e5f265eddaa8a Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Wed, 3 Jun 2020 09:59:36 -0600 Subject: caddypki: Add 'acme_server' Caddyfile directive --- modules/caddypki/acmeserver/acmeserver.go | 9 +++++++- modules/caddypki/acmeserver/caddyfile.go | 38 +++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 modules/caddypki/acmeserver/caddyfile.go (limited to 'modules/caddypki') diff --git a/modules/caddypki/acmeserver/acmeserver.go b/modules/caddypki/acmeserver/acmeserver.go index 8dc0f01..6023e06 100644 --- a/modules/caddypki/acmeserver/acmeserver.go +++ b/modules/caddypki/acmeserver/acmeserver.go @@ -48,13 +48,20 @@ type Handler struct { // The hostname or IP address by which ACME clients // will access the server. This is used to populate // the ACME directory endpoint. Default: localhost. - // TODO: this is probably not needed - check with smallstep + // COMPATIBILITY NOTE / TODO: This property may go away in the + // future, as it is currently only required due to + // limitations in the underlying library. Do not rely + // on this property long-term; check release notes. Host string `json:"host,omitempty"` // The path prefix under which to serve all ACME // endpoints. All other requests will not be served // by this handler and will be passed through to // the next one. Default: "/acme/" + // COMPATIBILITY NOTE / TODO: This property may go away in the + // future, as it is currently only required due to + // limitations in the underlying library. Do not rely + // on this property long-term; check release notes. PathPrefix string `json:"path_prefix,omitempty"` acmeEndpoints http.Handler diff --git a/modules/caddypki/acmeserver/caddyfile.go b/modules/caddypki/acmeserver/caddyfile.go new file mode 100644 index 0000000..6687460 --- /dev/null +++ b/modules/caddypki/acmeserver/caddyfile.go @@ -0,0 +1,38 @@ +// Copyright 2015 Matthew Holt and The Caddy Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package acmeserver + +import ( + "github.com/caddyserver/caddy/v2/caddyconfig/httpcaddyfile" + "github.com/caddyserver/caddy/v2/modules/caddyhttp" +) + +func init() { + httpcaddyfile.RegisterHandlerDirective("acme_server", parseACMEServer) +} + +// parseACMEServer sets up an ACME server handler from Caddyfile tokens. +// +// acme_server [] +// +func parseACMEServer(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHandler, error) { + var as Handler + for h.Next() { + if h.NextArg() { + return nil, h.ArgErr() + } + } + return as, nil +} -- cgit v1.2.3