about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEmile <hanemile@protonmail.com>2019-10-12 11:57:14 +0200
committerEmile <hanemile@protonmail.com>2019-10-12 11:57:14 +0200
commit217d2e36a1628f5db9bf5f67f5945a87c49dffee (patch)
treee840d2203a607c68a3f9a1fbe921ee75fd885bd2 /src
parent92dd4ed0893c01a0db394a4cdd1089ce3f12a0b0 (diff)
regex the username
Diffstat (limited to 'src')
-rw-r--r--src/http.go10
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