Skip to content

Commit

Permalink
Fix 45: Do not proxy requests for Widevine
Browse files Browse the repository at this point in the history
  • Loading branch information
jumde committed Jun 14, 2020
1 parent 6b31574 commit 2ac5333
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ before_install:
- curl -L -s https://github.com/golang/dep/releases/download/v${DEP_VERSION}/dep-linux-amd64
-o $GOPATH/bin/dep
- chmod +x $GOPATH/bin/dep
- go get -u github.com/golangci/golangci-lint/cmd/golangci-lint
- GO111MODULE=on go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.24.0
install:
- dep ensure
before_script:
Expand Down
12 changes: 10 additions & 2 deletions controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ import (
// PDF viewer extension install from chrome web store to the extension updater proxy
var PDFJSExtensionID = "oemmndcbldboiebfnladdacbdfmadadm"

// WidivineExtensionID is used to add an exception to pass the request for widivine
// directly to google servers
var WidivineExtensionID = "oimompecagnajdejgnnjijobebaeigek"

// AllExtensionsMap holds a mapping of extension ID to extension object.
// This list for tests is populated by extensions.OfferedExtensions.
// For normal operaitons of this server it is obtained from the AWS config
Expand Down Expand Up @@ -248,10 +252,14 @@ func UpdateExtensions(w http.ResponseWriter, r *http.Request) {
if len(r.URL.RawQuery) != 0 {
queryString = "?" + r.URL.RawQuery
}
host := "componentupdater.brave.com"
if updateRequest[0].ID == WidivineExtensionID {
host = "update.googleapis.com"
}
if jsonRequest {
http.Redirect(w, r, "https://componentupdater.brave.com/service/update2/json"+queryString, http.StatusTemporaryRedirect)
http.Redirect(w, r, "https://"+host+"/service/update2/json"+queryString, http.StatusTemporaryRedirect)
} else {
http.Redirect(w, r, "https://componentupdater.brave.com/service/update2"+queryString, http.StatusTemporaryRedirect)
http.Redirect(w, r, "https://"+host+"/service/update2"+queryString, http.StatusTemporaryRedirect)
}
return
}
Expand Down
5 changes: 5 additions & 0 deletions server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,11 @@ func TestUpdateExtensionsXML(t *testing.T) {
expectedResponse = ""
testCall(t, server, http.MethodPost, contentTypeXML, "?test=hi", requestBody, http.StatusTemporaryRedirect, expectedResponse, "https://componentupdater.brave.com/service/update2?test=hi")

// Requests for widevine should use update.googleapis.com directly without any proxy
requestBody = extensiontest.ExtensionRequestFnForXML(controller.WidivineExtensionID)("0.0.0")
expectedResponse = ""
testCall(t, server, http.MethodPost, contentTypeXML, "", requestBody, http.StatusTemporaryRedirect, expectedResponse, "https://update.googleapis.com/service/update2")

// Make sure a huge request body does not crash the server
data := make([]byte, 1024*1024*11) // 11 MiB
_, err := rand.Read(data)
Expand Down

0 comments on commit 2ac5333

Please sign in to comment.