From 217d2e36a1628f5db9bf5f67f5945a87c49dffee Mon Sep 17 00:00:00 2001 From: Emile Date: Sat, 12 Oct 2019 11:57:14 +0200 Subject: regex the username --- src/http.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/http.go b/src/http.go index 13276f7..c5e982d 100644 --- a/src/http.go +++ b/src/http.go @@ -9,6 +9,7 @@ import ( "log" "net/http" "os" + "regexp" "strings" "github.com/gorilla/mux" @@ -114,7 +115,14 @@ func isUniq(username string) bool { } func isValid(username string) bool { - if username == "traefik" || username == "register" { + // reserved subdomains + if username == "traefik" || username == "register" || username == "scoreboard" || username == "grafana" { + return false + } + + // valid Format + var validFormat = regexp.MustCompile("^[a-zA-Z0-9]{1,60}$") + if validFormat.MatchString(username) == false { return false } return true -- cgit 1.4.1