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

Side by Side Diff: tokenserver/appengine/impl/certconfig/rpc_fetch_crl.go

Issue 2988283002: tokenserver: Allow customizing list of OAuth scopes to use for CRL fetch. (Closed)
Patch Set: Created 3 years, 4 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 | « tokenserver/api/admin/v1/pb.discovery.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The LUCI Authors. 1 // Copyright 2016 The LUCI Authors.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 17 matching lines...) Expand all
28 ds "github.com/luci/gae/service/datastore" 28 ds "github.com/luci/gae/service/datastore"
29 "github.com/luci/luci-go/common/clock" 29 "github.com/luci/luci-go/common/clock"
30 "github.com/luci/luci-go/common/errors" 30 "github.com/luci/luci-go/common/errors"
31 "github.com/luci/luci-go/common/logging" 31 "github.com/luci/luci-go/common/logging"
32 "github.com/luci/luci-go/common/retry/transient" 32 "github.com/luci/luci-go/common/retry/transient"
33 "github.com/luci/luci-go/server/auth" 33 "github.com/luci/luci-go/server/auth"
34 34
35 "github.com/luci/luci-go/tokenserver/api/admin/v1" 35 "github.com/luci/luci-go/tokenserver/api/admin/v1"
36 ) 36 )
37 37
38 // List of OAuth scopes to use for token sent to CRL endpoint. 38 // List of OAuth scopes to use for token sent to CRL endpoint if config doesn't
39 var crlFetchScopes = []string{ 39 // specify 'oauth_scopes' field.
40 var crlFetchDefaultScopes = []string{
40 "https://www.googleapis.com/auth/userinfo.email", 41 "https://www.googleapis.com/auth/userinfo.email",
41 } 42 }
42 43
43 // FetchCRLRPC implements CertificateAuthorities.FetchCRL RPC method. 44 // FetchCRLRPC implements CertificateAuthorities.FetchCRL RPC method.
44 type FetchCRLRPC struct { 45 type FetchCRLRPC struct {
45 } 46 }
46 47
47 // FetchCRL makes the server fetch a CRL for some CA. 48 // FetchCRL makes the server fetch a CRL for some CA.
48 func (r *FetchCRLRPC) FetchCRL(c context.Context, req *admin.FetchCRLRequest) (* admin.FetchCRLResponse, error) { 49 func (r *FetchCRLRPC) FetchCRL(c context.Context, req *admin.FetchCRLRequest) (* admin.FetchCRLResponse, error) {
49 // Grab a corresponding CA entity. It contains URL of CRL to fetch. 50 // Grab a corresponding CA entity. It contains URL of CRL to fetch.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 //////////////////////////////////////////////////////////////////////////////// 106 ////////////////////////////////////////////////////////////////////////////////
106 107
107 // fetchCRL fetches a blob with der-encoded CRL from the CRL endpoint. 108 // fetchCRL fetches a blob with der-encoded CRL from the CRL endpoint.
108 // 109 //
109 // It knows how to use ETag headers to avoid fetching already known data. 110 // It knows how to use ETag headers to avoid fetching already known data.
110 // May return transient and fatal errors. 111 // May return transient and fatal errors.
111 func fetchCRL(c context.Context, cfg *admin.CertificateAuthorityConfig, knownETa g string) (blob []byte, etag string, err error) { 112 func fetchCRL(c context.Context, cfg *admin.CertificateAuthorityConfig, knownETa g string) (blob []byte, etag string, err error) {
112 // Pick auth or non-auth transport. 113 // Pick auth or non-auth transport.
113 var transport http.RoundTripper 114 var transport http.RoundTripper
114 if cfg.UseOauth { 115 if cfg.UseOauth {
115 » » transport, err = auth.GetRPCTransport(c, auth.AsSelf, auth.WithS copes(crlFetchScopes...)) 116 » » var scopes []string
117 » » if len(cfg.OauthScopes) != 0 {
118 » » » scopes = cfg.OauthScopes
119 » » } else {
120 » » » scopes = crlFetchDefaultScopes
121 » » }
122 » » transport, err = auth.GetRPCTransport(c, auth.AsSelf, auth.WithS copes(scopes...))
116 } else { 123 } else {
117 transport, err = auth.GetRPCTransport(c, auth.NoAuth) 124 transport, err = auth.GetRPCTransport(c, auth.NoAuth)
118 } 125 }
119 if err != nil { 126 if err != nil {
120 return nil, "", err 127 return nil, "", err
121 } 128 }
122 129
123 // Send the request with ETag related headers. 130 // Send the request with ETag related headers.
124 req, err := http.NewRequest("GET", cfg.CrlUrl, nil) 131 req, err := http.NewRequest("GET", cfg.CrlUrl, nil)
125 if err != nil { 132 if err != nil {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 } 231 }
225 return ds.Put(c, toPut) 232 return ds.Put(c, toPut)
226 }, nil) 233 }, nil)
227 if err != nil { 234 if err != nil {
228 return nil, transient.Tag.Apply(err) 235 return nil, transient.Tag.Apply(err)
229 } 236 }
230 237
231 logging.Infof(c, "CRL for %q is updated, entity version is %d", ca.CN, u pdated.EntityVersion) 238 logging.Infof(c, "CRL for %q is updated, entity version is %d", ca.CN, u pdated.EntityVersion)
232 return updated, nil 239 return updated, nil
233 } 240 }
OLDNEW
« no previous file with comments | « tokenserver/api/admin/v1/pb.discovery.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698