You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by mi...@apache.org on 2018/09/19 22:09:57 UTC
[trafficcontrol] 01/02: Fix TO Go to mask field
This is an automated email from the ASF dual-hosted git repository.
mitchell852 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
commit 506c9adba4f7f715e0c59a49036a6e1f312e27f6
Author: Robert Butts <ro...@apache.org>
AuthorDate: Wed Sep 19 15:59:12 2018 -0600
Fix TO Go to mask field
---
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)
}