trafficcontrol-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dgeli...@apache.org
Subject [trafficcontrol] 01/02: Fix TO Go to mask field
Date Thu, 20 Sep 2018 10:52:50 GMT
This is an automated email from the ASF dual-hosted git repository.

dgelinas pushed a commit to branch 3.0.x
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git

commit 1fa4ac4dfcb744ff5b19438b89d4e17d39725c61
Author: Robert Butts <rob@apache.org>
AuthorDate: Wed Sep 19 15:59:12 2018 -0600

    Fix TO Go to mask field
    
    (cherry picked from commit 2dabd12542a3a321631569bd0f607b52f795acc1)
---
 traffic_ops/traffic_ops_golang/server/detail.go | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/traffic_ops/traffic_ops_golang/server/detail.go b/traffic_ops/traffic_ops_golang/server/detail.go
index 24f43ca..5488c21 100644
--- a/traffic_ops/traffic_ops_golang/server/detail.go
+++ b/traffic_ops/traffic_ops_golang/server/detail.go
@@ -28,6 +28,7 @@ import (
 	"github.com/apache/trafficcontrol/lib/go-tc"
 	"github.com/apache/trafficcontrol/lib/go-util"
 	"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/api"
+	"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/auth"
 
 	"github.com/lib/pq"
 )
@@ -40,7 +41,7 @@ func GetDetailHandler(w http.ResponseWriter, r *http.Request) {
 	}
 	defer inf.Close()
 
-	servers, err := getDetailServers(inf.Tx.Tx, inf.Params["hostName"], -1, "", 0)
+	servers, err := getDetailServers(inf.Tx.Tx, inf.User, inf.Params["hostName"], -1, "", 0)
 	if err != nil {
 		api.HandleErr(w, r, inf.Tx.Tx, http.StatusInternalServerError, nil, errors.New("getting
detail servers: "+err.Error()))
 		return
@@ -89,7 +90,7 @@ func GetDetailParamHandler(w http.ResponseWriter, r *http.Request) {
 			return
 		}
 	}
-	servers, err := getDetailServers(inf.Tx.Tx, hostName, physLocationID, util.CamelToSnakeCase(orderBy),
limit)
+	servers, err := getDetailServers(inf.Tx.Tx, inf.User, hostName, physLocationID, util.CamelToSnakeCase(orderBy),
limit)
 	respVals := map[string]interface{}{
 		"orderby": orderBy,
 		"limit":   limit,
@@ -98,7 +99,7 @@ func GetDetailParamHandler(w http.ResponseWriter, r *http.Request) {
 	api.RespWriterVals(w, r, inf.Tx.Tx, respVals)(servers, err)
 }
 
-func getDetailServers(tx *sql.Tx, hostName string, physLocationID int, orderBy string, limit
int) ([]tc.ServerDetail, error) {
+func getDetailServers(tx *sql.Tx, user *auth.CurrentUser, hostName string, physLocationID
int, orderBy string, limit int) ([]tc.ServerDetail, error) {
 	allowedOrderByCols := map[string]string{
 		"":                 "",
 		"cachegroup":       "s.cachegroup",
@@ -220,6 +221,13 @@ JOIN type t ON s.type = t.id
 		if err := rows.Scan(&s.CacheGroup, &s.CDNName, pq.Array(&s.DeliveryServiceIDs),
&s.DomainName, &s.GUID, &s.HostName, &s.HTTPSPort, &s.ID, &s.ILOIPAddress,
&s.ILOIPGateway, &s.ILOIPNetmask, &s.ILOPassword, &s.ILOUsername, &s.InterfaceMTU,
&s.InterfaceName, &s.IP6Address, &s.IP6Gateway, &s.IPAddress, &s.IPGateway,
&s.IPNetmask, &s.MgmtIPAddress, &s.MgmtIPGateway, &s.MgmtIPNetmask, &s.OfflineReason,
&s.PhysLocation, &s.Profile, &s.ProfileDesc, &s.Rack, &s.RouterHostName,
&s.RouterPortName [...]
 			return nil, errors.New("Error scanning detail server: " + err.Error())
 		}
+
+		hiddenField := "********"
+		if user.PrivLevel < auth.PrivLevelAdmin {
+			s.ILOPassword = &hiddenField
+			s.XMPPPasswd = &hiddenField
+		}
+
 		servers = append(servers, s)
 		sIDs = append(sIDs, *s.ID)
 	}


Mime
View raw message