Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Unified Diff: milo/appengine/logdog/http.go

Issue 2695383002: milo: Enable Swarming LogDog log loading. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: milo/appengine/logdog/http.go
diff --git a/milo/appengine/logdog/http.go b/milo/appengine/logdog/http.go
index 0084d5f06716ef7aec524eb457ee1ca71123e7c0..b9fb377eca91a5b9c7323fc036dbe411b1f14205 100644
--- a/milo/appengine/logdog/http.go
+++ b/milo/appengine/logdog/http.go
@@ -70,11 +70,26 @@ func (s *AnnotationStreamHandler) Render(c context.Context, req *http.Request, p
}, nil
}
+func resolveHost(host string) (string, error) {
+ // Resolveour our Host, and validate it against a host whitelist.
+ switch host {
+ case "":
+ return defaultLogDogHost, nil
+ case defaultLogDogHost, "luci-logdog-dev.appspot.com":
+ return host, nil
+ default:
+ return "", errors.Reason("host %(host)q is not whitelisted").
+ D("host", host).
+ Err()
+ }
+}
+
// NewClient generates a new LogDog client that issues requests on behalf of the
// current user.
func NewClient(c context.Context, host string) (*coordinator.Client, error) {
- if host == "" {
- host = defaultLogDogHost
+ var err error
+ if host, err = resolveHost(host); err != nil {
+ return nil, err
}
// Initialize the LogDog client authentication.

Powered by Google App Engine
This is Rietveld 408576698