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

Side by Side Diff: common/auth/localauth/rpcs/getoauthtoken.go

Issue 2951553002: Extend LUCI_CONTEXT["local_auth"] protocol to understand accounts. (Closed)
Patch Set: few more tests Created 3 years, 6 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 | « common/auth/localauth/ctx_test.go ('k') | common/auth/localauth/server.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 2017 The LUCI Authors. All rights reserved. 1 // Copyright 2017 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 rpcs 5 package rpcs
6 6
7 import ( 7 import (
8 » "fmt" 8 » "github.com/luci/luci-go/common/errors"
9 ) 9 )
10 10
11 // GetOAuthTokenRequest is parameters for GetOAuthToken RPC call. 11 // GetOAuthTokenRequest is parameters for GetOAuthToken RPC call.
12 type GetOAuthTokenRequest struct { 12 type GetOAuthTokenRequest struct {
13 » Scopes []string `json:"scopes"` 13 » Scopes []string `json:"scopes"`
14 » Secret []byte `json:"secret"` 14 » Secret []byte `json:"secret"`
15 » AccountID string `json:"account_id"`
15 } 16 }
16 17
17 // Validate checks that scopes and secret are set. 18 // Validate checks that the request is structurally valid.
18 func (r *GetOAuthTokenRequest) Validate() error { 19 func (r *GetOAuthTokenRequest) Validate() error {
19 switch { 20 switch {
20 case len(r.Scopes) == 0: 21 case len(r.Scopes) == 0:
21 » » return fmt.Errorf(`Field "scopes" is required.`) 22 » » return errors.New(`field "scopes" is required`)
22 case len(r.Secret) == 0: 23 case len(r.Secret) == 0:
23 » » return fmt.Errorf(`Field "secret" is required.`) 24 » » return errors.New(`field "secret" is required`)
24 } 25 }
26 // TODO(vadimsh): Uncomment when all old auth server are turned off.
27 //case r.AccountID == "":
28 // return errors.New(`field "account_id" is required`)
29 //}
25 return nil 30 return nil
26 } 31 }
27 32
28 // GetOAuthTokenResponse is returned by GetOAuthToken RPC call. 33 // GetOAuthTokenResponse is returned by GetOAuthToken RPC call.
29 type GetOAuthTokenResponse struct { 34 type GetOAuthTokenResponse struct {
30 BaseResponse 35 BaseResponse
31 36
32 AccessToken string `json:"access_token"` 37 AccessToken string `json:"access_token"`
33 Expiry int64 `json:"expiry"` 38 Expiry int64 `json:"expiry"`
34 } 39 }
OLDNEW
« no previous file with comments | « common/auth/localauth/ctx_test.go ('k') | common/auth/localauth/server.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698