From 94f0bfdc2d658486069f50319c2eb46206c0ee92 Mon Sep 17 00:00:00 2001 From: Stefan Bethke Date: Mon, 20 Aug 2018 19:22:27 +0000 Subject: [PATCH] Make registration endpoint URI configurable This allows hiding the registration while leaving it enabled and exposed to the wider network. --- README.md | 3 +++ config.cfg | 2 ++ main.go | 7 ++++++- types.go | 1 + 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8a8384b2..979c46ab 100644 --- a/README.md +++ b/README.md @@ -300,6 +300,9 @@ header_name = "X-Forwarded-For" ## Changelog +- unreleased + - New + - Registration URI configurable - v0.5 - New - Configurable certificate cache directory diff --git a/config.cfg b/config.cfg index 93dd663d..1008d315 100644 --- a/config.cfg +++ b/config.cfg @@ -38,6 +38,8 @@ api_domain = "" ip = "0.0.0.0" # disable registration endpoint disable_registration = false +# endpoint URI for registration +#registration_uri = "/register" # autocert HTTP port, eg. 80 for answering Let's Encrypt HTTP-01 challenges. Mandatory if using tls = "letsencrypt". autocert_port = "80" # listen port, eg. 443 for default HTTPS diff --git a/main.go b/main.go index 2eb135a1..643bedf4 100644 --- a/main.go +++ b/main.go @@ -78,7 +78,12 @@ func startHTTPAPI() { c.Log = stdlog.New(logwriter, "", 0) } if !Config.API.DisableRegistration { - api.POST("/register", webRegisterPost) + uri := Config.API.RegistrationUri + if (uri == "") { + uri = "/register" + } + log.WithFields(log.Fields{"register_uri": uri}).Debug("Register endpoint") + api.POST(uri, webRegisterPost) } api.POST("/update", Auth(webUpdatePost)) diff --git a/types.go b/types.go index a615a596..7bbeb1ad 100644 --- a/types.go +++ b/types.go @@ -54,6 +54,7 @@ type httpapi struct { Domain string `toml:"api_domain"` IP string DisableRegistration bool `toml:"disable_registration"` + RegistrationUri string `toml:"registration_uri"` AutocertPort string `toml:"autocert_port"` Port string `toml:"port"` TLS string