File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -1382,15 +1382,23 @@ func (r *RedirectionError) Is(target error) bool {
13821382 r .Location != nil && v .Location != nil && r .Location .String () == v .Location .String ()) // or they are both not nil and marshaled identically
13831383}
13841384
1385- // sanitizeURL redacts the client_secret parameter from the URL which may be
1385+ var sensitiveParams = []string {"client_secret" , "access_token" , "token" }
1386+
1387+ // sanitizeURL redacts sensitive parameters from the URL which may be
13861388// exposed to the user.
13871389func sanitizeURL (uri * url.URL ) * url.URL {
13881390 if uri == nil {
13891391 return nil
13901392 }
13911393 params := uri .Query ()
1392- if len (params .Get ("client_secret" )) > 0 {
1393- params .Set ("client_secret" , "REDACTED" )
1394+ var redacted bool
1395+ for _ , p := range sensitiveParams {
1396+ if len (params .Get (p )) > 0 {
1397+ params .Set (p , "REDACTED" )
1398+ redacted = true
1399+ }
1400+ }
1401+ if redacted {
13941402 uri .RawQuery = params .Encode ()
13951403 }
13961404 return uri
Original file line number Diff line number Diff line change @@ -2174,6 +2174,9 @@ func TestSanitizeURL(t *testing.T) {
21742174 {"/?a=b" , "/?a=b" },
21752175 {"/?a=b&client_secret=secret" , "/?a=b&client_secret=REDACTED" },
21762176 {"/?a=b&client_id=id&client_secret=secret" , "/?a=b&client_id=id&client_secret=REDACTED" },
2177+ {"/?a=b&access_token=secret" , "/?a=b&access_token=REDACTED" },
2178+ {"/?a=b&token=secret" , "/?a=b&token=REDACTED" },
2179+ {"/?client_secret=s&access_token=t&token=u" , "/?access_token=REDACTED&client_secret=REDACTED&token=REDACTED" },
21772180 }
21782181
21792182 for _ , tt := range tests {
You can’t perform that action at this time.
0 commit comments