| OLD | NEW |
| 1 # Copyright 2014 The Swarming Authors. All rights reserved. | 1 # Copyright 2014 The Swarming Authors. All rights reserved. |
| 2 # Use of this source code is governed by the Apache v2.0 license that can be | 2 # Use of this source code is governed by the Apache v2.0 license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Auth management REST API.""" | 5 """Auth management REST API.""" |
| 6 | 6 |
| 7 import base64 | 7 import base64 |
| 8 import functools | 8 import functools |
| 9 import logging | 9 import logging |
| 10 import urllib | 10 import urllib |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 def is_config_locked(): | 94 def is_config_locked(): |
| 95 """Returns True to forbid configuration changing API calls. | 95 """Returns True to forbid configuration changing API calls. |
| 96 | 96 |
| 97 If is_config_locked returns True API requests that change configuration will | 97 If is_config_locked returns True API requests that change configuration will |
| 98 return HTTP 409 error. | 98 return HTTP 409 error. |
| 99 | 99 |
| 100 A configuration is subset of AuthDB that changes infrequently: | 100 A configuration is subset of AuthDB that changes infrequently: |
| 101 * OAuth client_id whitelist | 101 * OAuth client_id whitelist |
| 102 * IP whitelist | 102 * IP whitelist |
| 103 | 103 |
| 104 Used by auth_service that utilizes luci-config for config management. | 104 Used by auth_service that utilizes config_service for config management. |
| 105 """ | 105 """ |
| 106 return _is_config_locked_cb() if _is_config_locked_cb else False | 106 return _is_config_locked_cb() if _is_config_locked_cb else False |
| 107 | 107 |
| 108 | 108 |
| 109 def set_config_locked(locked_callback): | 109 def set_config_locked(locked_callback): |
| 110 """Sets a function that returns True if configuration is locked.""" | 110 """Sets a function that returns True if configuration is locked.""" |
| 111 global _is_config_locked_cb | 111 global _is_config_locked_cb |
| 112 _is_config_locked_cb = locked_callback | 112 _is_config_locked_cb = locked_callback |
| 113 | 113 |
| 114 | 114 |
| (...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 mode = 'replica' | 762 mode = 'replica' |
| 763 else: | 763 else: |
| 764 assert model.is_standalone() | 764 assert model.is_standalone() |
| 765 mode = 'standalone' | 765 mode = 'standalone' |
| 766 state = model.get_replication_state() or model.AuthReplicationState() | 766 state = model.get_replication_state() or model.AuthReplicationState() |
| 767 self.send_response({ | 767 self.send_response({ |
| 768 'auth_code_version': version.__version__, | 768 'auth_code_version': version.__version__, |
| 769 'mode': mode, | 769 'mode': mode, |
| 770 'replication_state': state.to_serializable_dict(), | 770 'replication_state': state.to_serializable_dict(), |
| 771 }) | 771 }) |
| OLD | NEW |