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

Side by Side Diff: server/auth/internal/fetch.go

Issue 2386643003: auth: Make luci-go services trust signatures produced by the token server. (Closed)
Patch Set: add tests Created 4 years, 2 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 unified diff | Download patch
« no previous file with comments | « server/auth/delegation/minter_test.go ('k') | server/auth/internal/testing.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The LUCI Authors. All rights reserved. 1 // Copyright 2015 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package internal 5 package internal
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "encoding/json" 9 "encoding/json"
10 "fmt" 10 "fmt"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 func (r *Request) Do(c context.Context) error { 64 func (r *Request) Do(c context.Context) error {
65 // Grab a client first. Use same client for all retry attempts. 65 // Grab a client first. Use same client for all retry attempts.
66 var client *http.Client 66 var client *http.Client
67 if clientFactory != nil { 67 if clientFactory != nil {
68 var err error 68 var err error
69 if client, err = clientFactory(c, r.Scopes); err != nil { 69 if client, err = clientFactory(c, r.Scopes); err != nil {
70 return err 70 return err
71 } 71 }
72 } else { 72 } else {
73 client = http.DefaultClient 73 client = http.DefaultClient
74 if testTransport := c.Value(&testTransportKey); testTransport != nil {
75 client = &http.Client{Transport: testTransport.(http.Rou ndTripper)}
76 }
74 } 77 }
75 78
76 // Prepare a blob with the request body. Marshal it once, to avoid 79 // Prepare a blob with the request body. Marshal it once, to avoid
77 // remarshaling on retries. 80 // remarshaling on retries.
78 isJSON := false 81 isJSON := false
79 var bodyBlob []byte 82 var bodyBlob []byte
80 if blob, ok := r.Body.([]byte); ok { 83 if blob, ok := r.Body.([]byte); ok {
81 bodyBlob = blob 84 bodyBlob = blob
82 } else if r.Body != nil { 85 } else if r.Body != nil {
83 var err error 86 var err error
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 return err 138 return err
136 } 139 }
137 if val != nil { 140 if val != nil {
138 if err = json.NewDecoder(resp.Body).Decode(val); err != nil { 141 if err = json.NewDecoder(resp.Body).Decode(val); err != nil {
139 logging.Errorf(c, "auth: URL fetch failed, bad JSON - %s ", err) 142 logging.Errorf(c, "auth: URL fetch failed, bad JSON - %s ", err)
140 return fmt.Errorf("auth: can't deserialize JSON at %q - %s", r.URL, err) 143 return fmt.Errorf("auth: can't deserialize JSON at %q - %s", r.URL, err)
141 } 144 }
142 } 145 }
143 return nil 146 return nil
144 } 147 }
OLDNEW
« no previous file with comments | « server/auth/delegation/minter_test.go ('k') | server/auth/internal/testing.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698