| OLD | NEW |
| 1 // Copyright 2016 The LUCI Authors. All rights reserved. | 1 // Copyright 2016 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 auth | 5 package auth |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "net/http" | 8 "net/http" |
| 9 "time" | 9 "time" |
| 10 | 10 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 // expected to live for at least 1-2 mins. | 40 // expected to live for at least 1-2 mins. |
| 41 AccessTokenProvider func(c context.Context, scopes []string) (auth.Token
, error) | 41 AccessTokenProvider func(c context.Context, scopes []string) (auth.Token
, error) |
| 42 | 42 |
| 43 // AnonymousTransport returns http.RoundTriper that can make unauthentic
ated | 43 // AnonymousTransport returns http.RoundTriper that can make unauthentic
ated |
| 44 // HTTP requests. | 44 // HTTP requests. |
| 45 // | 45 // |
| 46 // The returned round tripper is assumed to be bound to the context and
won't | 46 // The returned round tripper is assumed to be bound to the context and
won't |
| 47 // outlive it. | 47 // outlive it. |
| 48 AnonymousTransport func(c context.Context) http.RoundTripper | 48 AnonymousTransport func(c context.Context) http.RoundTripper |
| 49 | 49 |
| 50 » // GlobalCache implements service-global strongly consistent cache. | 50 » // Cache implements a strongly consistent cache. |
| 51 // | 51 // |
| 52 // Usually backed by memcache. Should do namespacing itself (i.e. the au
th | 52 // Usually backed by memcache. Should do namespacing itself (i.e. the au
th |
| 53 // library assumes full ownership of the keyspace). | 53 // library assumes full ownership of the keyspace). |
| 54 » GlobalCache GlobalCache | 54 » Cache Cache |
| 55 } | 55 } |
| 56 | 56 |
| 57 // GlobalCache implements service-global strongly consistent cache. | 57 // Cache implements a strongly consistent cache. |
| 58 type GlobalCache interface { | 58 type Cache interface { |
| 59 // Get returns a cached item or (nil, nil) if it's not in the cache. | 59 // Get returns a cached item or (nil, nil) if it's not in the cache. |
| 60 // | 60 // |
| 61 // Any returned error is transient error. | 61 // Any returned error is transient error. |
| 62 Get(c context.Context, key string) ([]byte, error) | 62 Get(c context.Context, key string) ([]byte, error) |
| 63 | 63 |
| 64 // Set unconditionally overwrites an item in the cache. | 64 // Set unconditionally overwrites an item in the cache. |
| 65 // | 65 // |
| 66 // If 'exp' is zero, the item will have no expiration time. | 66 // If 'exp' is zero, the item will have no expiration time. |
| 67 // | 67 // |
| 68 // Any returned error is transient error. | 68 // Any returned error is transient error. |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 return authdb.ErroringDB{Error: ErrNotConfigured}, nil | 114 return authdb.ErroringDB{Error: ErrNotConfigured}, nil |
| 115 } | 115 } |
| 116 | 116 |
| 117 // GetSigner extracts Signer from the context. Returns nil if no Signer is set. | 117 // GetSigner extracts Signer from the context. Returns nil if no Signer is set. |
| 118 func GetSigner(c context.Context) signing.Signer { | 118 func GetSigner(c context.Context) signing.Signer { |
| 119 if cfg := GetConfig(c); cfg != nil { | 119 if cfg := GetConfig(c); cfg != nil { |
| 120 return cfg.Signer | 120 return cfg.Signer |
| 121 } | 121 } |
| 122 return nil | 122 return nil |
| 123 } | 123 } |
| OLD | NEW |