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

Side by Side Diff: server/prpc/auth.go

Issue 1605363002: common/prpc, tools/cmd/cproto: prpc client (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: rebased and addressed comments Created 4 years, 11 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/retry/transient.go ('k') | server/prpc/decoding.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package prpc 5 package prpc
6 6
7 import ( 7 import (
8 "sync" 8 "sync"
9 9
10 "github.com/luci/luci-go/server/auth" 10 "github.com/luci/luci-go/server/auth"
11 ) 11 )
12 12
13 var defaultAuth = struct { 13 var defaultAuth = struct {
14 sync.RWMutex 14 sync.RWMutex
15 Authenticator auth.Authenticator 15 Authenticator auth.Authenticator
16 }{} 16 }{}
17 17
18 // RegisterDefaultAuth sets a default authenticator that is used unless 18 // RegisterDefaultAuth sets a default authenticator that is used unless
19 // Server.CustomAuthenticator is true. 19 // Server.CustomAuthenticator is true.
20 // Panics if a is nil or called twice. 20 // Panics if a is nil or called twice.
21 func RegisterDefaultAuth(a auth.Authenticator) { 21 func RegisterDefaultAuth(a auth.Authenticator) {
22 if a == nil { 22 if a == nil {
23 » » panicf("a is nil") 23 » » panic("a is nil")
24 } 24 }
25 defaultAuth.Lock() 25 defaultAuth.Lock()
26 defer defaultAuth.Unlock() 26 defer defaultAuth.Unlock()
27 if defaultAuth.Authenticator != nil { 27 if defaultAuth.Authenticator != nil {
28 » » panicf("default prpc authenticator is already set") 28 » » panic("default prpc authenticator is already set")
29 } 29 }
30 defaultAuth.Authenticator = a 30 defaultAuth.Authenticator = a
31 } 31 }
32 32
33 // GetDefaultAuth returns the default authenticator set by RegisterDefaultAuth 33 // GetDefaultAuth returns the default authenticator set by RegisterDefaultAuth
34 // or nil if not registered. 34 // or nil if not registered.
35 func GetDefaultAuth() auth.Authenticator { 35 func GetDefaultAuth() auth.Authenticator {
36 defaultAuth.RLock() 36 defaultAuth.RLock()
37 defer defaultAuth.RUnlock() 37 defer defaultAuth.RUnlock()
38 return defaultAuth.Authenticator 38 return defaultAuth.Authenticator
39 } 39 }
OLDNEW
« no previous file with comments | « common/retry/transient.go ('k') | server/prpc/decoding.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698