diff --git a/README.md b/README.md index 40344fa..9853cc7 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,8 @@ By default publapi listens on 127.0.0.1:3000. You can change the port with the e Additionally, you need to set the variable PUBLAPI_EMAIL_SHOUTRRRURL and PUBLAPI_NOTIFY_SHOUTRRRURL in order for signup notifications to work. URL Format can be found at https://containrrr.dev/shoutrrr/v0.5. +You can also set PUBLAPI_SIGNUP_IP to make sure signup requests can only be made from one IP. + ## Usage Currently, PublAPI has only two routes, /users and /signup. diff --git a/pages/signup.go b/pages/signup.go index 4122f19..68a9f35 100644 --- a/pages/signup.go +++ b/pages/signup.go @@ -11,7 +11,13 @@ import ( // SignupPage is the signup page handler func SignupPage(c *fiber.Ctx) error { - + SignupIP, SignupIPExists := os.LookupEnv("PUBLAPI_SIGNUP_IP") + if SignupIPExists == true { + if c.IP() != SignupIP { + log.Info("Request made from invalid IP: ", c.IP()) + return c.SendStatus(fiber.StatusForbidden) + } + } username := c.FormValue("username") email := c.FormValue("email") ssh := c.FormValue("ssh")