diff --git a/engine/config/config.go b/engine/config/config.go index 03802f0..c505305 100644 --- a/engine/config/config.go +++ b/engine/config/config.go @@ -128,9 +128,10 @@ type MiscConfig struct { } type UIConfig struct { - EnablePublicGraphs bool - DisableGraphsForBlueTeam bool - ShowAnnouncementsForRedTeam bool + EnablePublicGraphs bool + DisableGraphsForBlueTeam bool + AllowNonAnonymizedGraphsForBlueTeam bool + ShowAnnouncementsForRedTeam bool } type User struct { diff --git a/www/api/graphs.go b/www/api/graphs.go index 2979405..4307876 100644 --- a/www/api/graphs.go +++ b/www/api/graphs.go @@ -77,6 +77,12 @@ func GetServiceStatus(w http.ResponseWriter, r *http.Request) { series = append(series, s) } + if shouldScrub(r) { + for i := range series { + series[i].Name = "Team" + } + } + data := map[string]any{"series": series, "roundID": round.ID} WriteJSON(w, http.StatusOK, data) } @@ -126,15 +132,8 @@ func GetScoreStatus(w http.ResponseWriter, r *http.Request) { } } - if r.Context().Value("roles") != nil { - req_roles := r.Context().Value("roles").([]string) - if !slices.Contains(req_roles, "admin") { - for i, _ := range series { - series[i].Name = "Team" - } - } - } else { - for i, _ := range series { + if shouldScrub(r) { + for i := range series { series[i].Name = "Team" } } @@ -207,15 +206,8 @@ func GetUptimeStatus(w http.ResponseWriter, r *http.Request) { series = append(series, s) } - if r.Context().Value("roles") != nil { - req_roles := r.Context().Value("roles").([]string) - if !slices.Contains(req_roles, "admin") { - for i, _ := range series { - series[i].Name = "Team" - } - } - } else { - for i, _ := range series { + if shouldScrub(r) { + for i := range series { series[i].Name = "Team" } } @@ -223,3 +215,17 @@ func GetUptimeStatus(w http.ResponseWriter, r *http.Request) { data := map[string]any{"series": series} WriteJSON(w, http.StatusOK, data) } + +func shouldScrub(r *http.Request) bool { + if r.Context().Value("roles") != nil { + req_roles := r.Context().Value("roles").([]string) + if slices.Contains(req_roles, "admin") { + return false + } + } + + if conf.UISettings.AllowNonAnonymizedGraphsForBlueTeam { + return false + } + return true +}