diff options
author | Emile <hanemile@protonmail.com> | 2019-10-12 11:57:14 +0200 |
---|---|---|
committer | Emile <hanemile@protonmail.com> | 2019-10-12 11:57:14 +0200 |
commit | 217d2e36a1628f5db9bf5f67f5945a87c49dffee (patch) | |
tree | e840d2203a607c68a3f9a1fbe921ee75fd885bd2 /src | |
parent | 92dd4ed0893c01a0db394a4cdd1089ce3f12a0b0 (diff) |
regex the username
Diffstat (limited to 'src')
-rw-r--r-- | src/http.go | 10 |
1 files changed, 9 insertions, 1 deletions
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 |