Skip to content

Commit

Permalink
Merge pull request #44 from Comcast/patch/403LoggingRollback
Browse files Browse the repository at this point in the history
Patch/403 logging rollback
  • Loading branch information
schmidtw authored Jan 6, 2018
2 parents 688f96c + 7997f9d commit 1c15086
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 19 deletions.
8 changes: 5 additions & 3 deletions etc/tr1d1um/tr1d1um.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"fqdn": "localhost",
"server": "localhost",
"version": "-",
"region": "-",
"flavor": "",

"primary": {
"address": ":6003"
Expand Down Expand Up @@ -44,6 +47,5 @@
},

"targetURL": "localhost:6000",
"supportedServices": ["config"],
"version", "v2"
"supportedServices": ["config"]
}
12 changes: 1 addition & 11 deletions src/tr1d1um/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package main
import (
"bytes"
"fmt"
"math"
"net/http"
"strings"

Expand Down Expand Up @@ -132,16 +131,7 @@ func (ch *ConversionHandler) ServeHTTP(origin http.ResponseWriter, req *http.Req
errorLogger.Log(logging.MessageKey(), "error in retry execution", logging.ErrorKey(), err)
}

//temporary debugging log for weird 403 cases
tr1Response := tr1Resp.(*Tr1d1umResponse)
if tr1Response.Code == http.StatusForbidden {
authVal := req.Header.Get("Authorization")
n, perc := float64(len(authVal)), float64(0.9)
desiredLength := int(math.Floor(n * perc))
debugLogger.Log(logging.MessageKey(), "first 90% of auth value", "authValLength", n, "90PPrefix", authVal[:desiredLength])
}

TransferResponse(tr1Response, origin)
TransferResponse(tr1Resp.(*Tr1d1umResponse), origin)
}

//HandleStat handles the differentiated STAT command
Expand Down
9 changes: 4 additions & 5 deletions src/tr1d1um/tr1d1um.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ import (

//convenient global values
const (
applicationName = "tr1d1um"
baseURI = "/api"
applicationName, apiBase = "tr1d1um", "/api/v2"

DefaultKeyID = "current"
defaultClientTimeout = "30s"
Expand Down Expand Up @@ -105,7 +104,7 @@ func tr1d1um(arguments []string) (exitCode int) {
conversionHandler := SetUpHandler(v, logger)

r := mux.NewRouter()
baseRouter := r.PathPrefix(fmt.Sprintf("%s/%s", baseURI, v.GetString("version"))).Subrouter()
baseRouter := r.PathPrefix(apiBase).Subrouter()

AddRoutes(baseRouter, preHandler, conversionHandler)

Expand Down Expand Up @@ -160,7 +159,7 @@ func ConfigureWebHooks(baseRouter *mux.Router, root *mux.Router, preHandler *ali

selfURL := &url.URL{
Scheme: "https",
Host: v.GetString("fqdn") + v.GetString("primary.address"),
Host: v.GetString("server") + v.GetString("primary.address"),
}

webHookFactory.Initialize(root, selfURL, webHookHandler, logger, nil)
Expand Down Expand Up @@ -225,7 +224,7 @@ func SetUpHandler(v *viper.Viper, logger log.Logger) (cHandler *ConversionHandle
},
RetryStrategy: RetryStrategyFactory{}.NewRetryStrategy(logger, retryInterval, maxRetries,
ShouldRetryOnResponse, OnRetryInternalFailure),
WRPRequestURL: fmt.Sprintf("%s%s/%s/device", v.GetString(targetURLKey), baseURI, v.GetString("version")),
WRPRequestURL: fmt.Sprintf("%s%s/device", v.GetString(targetURLKey), apiBase),
TargetURL: v.GetString(targetURLKey),
}

Expand Down

0 comments on commit 1c15086

Please sign in to comment.