| OLD | NEW |
| 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 14 matching lines...) Expand all Loading... |
| 25 "github.com/luci/luci-go/server/auth/signing" | 25 "github.com/luci/luci-go/server/auth/signing" |
| 26 ) | 26 ) |
| 27 | 27 |
| 28 // Config contains global configuration of the auth library. | 28 // Config contains global configuration of the auth library. |
| 29 // | 29 // |
| 30 // This configuration adjusts the library to the particular execution | 30 // This configuration adjusts the library to the particular execution |
| 31 // environment (GAE, Flex, whatever). It contains concrete implementations of | 31 // environment (GAE, Flex, whatever). It contains concrete implementations of |
| 32 // various interfaces used by the library. | 32 // various interfaces used by the library. |
| 33 // | 33 // |
| 34 // It lives in the context and must be installed there by some root middleware | 34 // It lives in the context and must be installed there by some root middleware |
| 35 // (via ModifyContext call). | 35 // (via ModifyConfig call). |
| 36 type Config struct { | 36 type Config struct { |
| 37 // DBProvider is a callback that returns most recent DB instance. | 37 // DBProvider is a callback that returns most recent DB instance. |
| 38 // | 38 // |
| 39 // DB represents a snapshot of user groups used for authorization checks
. | 39 // DB represents a snapshot of user groups used for authorization checks
. |
| 40 DBProvider func(c context.Context) (authdb.DB, error) | 40 DBProvider func(c context.Context) (authdb.DB, error) |
| 41 | 41 |
| 42 // Signer possesses the service's private key and can sign blobs with it
. | 42 // Signer possesses the service's private key and can sign blobs with it
. |
| 43 // | 43 // |
| 44 // It provides the bundle with corresponding public keys and information
about | 44 // It provides the bundle with corresponding public keys and information
about |
| 45 // the service account they belong too (the service's own identity). | 45 // the service account they belong too (the service's own identity). |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 // | 120 // |
| 121 // If no factory is installed, returns DB that forbids everything and logs | 121 // If no factory is installed, returns DB that forbids everything and logs |
| 122 // errors. It is often good enough for unit tests that do not care about | 122 // errors. It is often good enough for unit tests that do not care about |
| 123 // authorization, and still not horribly bad if accidentally used in production. | 123 // authorization, and still not horribly bad if accidentally used in production. |
| 124 func GetDB(c context.Context) (authdb.DB, error) { | 124 func GetDB(c context.Context) (authdb.DB, error) { |
| 125 if cfg := getConfig(c); cfg != nil && cfg.DBProvider != nil { | 125 if cfg := getConfig(c); cfg != nil && cfg.DBProvider != nil { |
| 126 return cfg.DBProvider(c) | 126 return cfg.DBProvider(c) |
| 127 } | 127 } |
| 128 return authdb.ErroringDB{Error: ErrNotConfigured}, nil | 128 return authdb.ErroringDB{Error: ErrNotConfigured}, nil |
| 129 } | 129 } |
| OLD | NEW |