Skip to content
Snippets Groups Projects
Commit 76529f01 authored by Jano Hendriks's avatar Jano Hendriks
Browse files

Mask authorization header for raygun logs

parent 1d1f5573
Branches
Tags v1.85.0
No related merge requests found
......@@ -3,6 +3,7 @@ package logs
import (
"errors"
"fmt"
"gitlab.bob.co.za/bob-public-utils/bobgroup-go-utils/utils"
"net/http"
"net/url"
"os"
......@@ -230,6 +231,15 @@ func fakeHttpRequest() *http.Request {
return nil
}
// Mask authorization header for raygun logs
headers := utils.DeepCopy(apiRequest.MultiValueHeaders).(map[string][]string)
if len(headers["authorization"]) != 0 {
headers["authorization"] = []string{"***"}
}
if len(headers["Authorization"]) != 0 {
headers["Authorization"] = []string{"***"}
}
requestURL := url.URL{
Path: apiRequest.Path,
Host: apiRequest.Headers["Host"],
......@@ -237,7 +247,7 @@ func fakeHttpRequest() *http.Request {
request := http.Request{
Method: apiRequest.HTTPMethod,
URL: &requestURL,
Header: apiRequest.MultiValueHeaders,
Header: headers,
}
return &request
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment