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

Side by Side Diff: appengine/components/components/config/common.py

Issue 1224913002: luci-config: fine-grained acls (Closed) Base URL: git@github.com:luci/luci-py.git@master
Patch Set: fine-grained acls for service configs Created 5 years, 5 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
OLDNEW
1 # Copyright 2015 The Swarming Authors. All rights reserved. 1 # Copyright 2015 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 import re 5 import re
6 6
7 from google.appengine.api import app_identity 7 from google.appengine.api import app_identity
8 from google.appengine.api import lib_config 8 from google.appengine.api import lib_config
9 from google.appengine.ext import ndb 9 from google.appengine.ext import ndb
10 10
11 # Config component is using google.protobuf package, it requires some python 11 # Config component is using google.protobuf package, it requires some python
12 # package magic hacking. 12 # package magic hacking.
13 from components import utils 13 from components import utils
14 utils.fix_protobuf_package() 14 utils.fix_protobuf_package()
15 15
16 from google import protobuf 16 from google import protobuf
17 17
18 from components import auth
18 from components import utils 19 from components import utils
19 from components.datastore_utils import config 20 from components.datastore_utils import config
20 21
21 22
22 ################################################################################ 23 ################################################################################
23 # Patterns 24 # Patterns
24 25
25 26
26 SERVICE_ID_PATTERN = r'[a-z0-9\-_]+' 27 SERVICE_ID_PATTERN = r'[a-z0-9\-_]+'
27 SERVICE_ID_RGX = re.compile(r'^%s$' % SERVICE_ID_PATTERN) 28 SERVICE_ID_RGX = re.compile(r'^%s$' % SERVICE_ID_PATTERN)
28 SERVICE_CONFIG_SET_RGX = re.compile(r'^services/(%s)$' % SERVICE_ID_PATTERN) 29 SERVICE_CONFIG_SET_RGX = re.compile(r'^services/(%s)$' % SERVICE_ID_PATTERN)
29 30
30 PROJECT_ID_PATTERN = SERVICE_ID_PATTERN 31 PROJECT_ID_PATTERN = SERVICE_ID_PATTERN
31 PROJECT_ID_RGX = re.compile(r'^%s$' % PROJECT_ID_PATTERN) 32 PROJECT_ID_RGX = re.compile(r'^%s$' % PROJECT_ID_PATTERN)
32 PROJECT_CONFIG_SET_RGX = re.compile(r'^projects/(%s)$' % PROJECT_ID_PATTERN) 33 PROJECT_CONFIG_SET_RGX = re.compile(r'^projects/(%s)$' % PROJECT_ID_PATTERN)
33 34
34 REF_CONFIG_SET_RGX = re.compile( 35 REF_CONFIG_SET_RGX = re.compile(
35 r'^projects/(%s)/(refs/.+$)' % PROJECT_ID_PATTERN) 36 r'^projects/(%s)/(refs/.+)$' % PROJECT_ID_PATTERN)
36 37
37 ALL_CONFIG_SET_RGX = [ 38 ALL_CONFIG_SET_RGX = [
38 SERVICE_CONFIG_SET_RGX, 39 SERVICE_CONFIG_SET_RGX,
39 PROJECT_CONFIG_SET_RGX, 40 PROJECT_CONFIG_SET_RGX,
40 REF_CONFIG_SET_RGX, 41 REF_CONFIG_SET_RGX,
41 ] 42 ]
42 43
43 44
44 ################################################################################ 45 ################################################################################
45 # Settings 46 # Settings
46 47
47 48
48 class ConstantConfig(object): 49 class ConstantConfig(object):
49 # In filesystem mode, the directory where configs are read from. 50 # In filesystem mode, the directory where configs are read from.
50 CONFIG_DIR = 'configs' 51 CONFIG_DIR = 'configs'
51 52
52 53
53 CONSTANTS = lib_config.register('components_config', ConstantConfig.__dict__) 54 CONSTANTS = lib_config.register('components_config', ConstantConfig.__dict__)
54 55
55 56
56 class ConfigSettings(config.GlobalConfig): 57 class ConfigSettings(config.GlobalConfig):
57 # Hostname of the config service. 58 # Hostname of the config service.
58 service_hostname = ndb.StringProperty(indexed=False) 59 service_hostname = ndb.StringProperty(indexed=False)
60 # Identity account used by config service.
61 trusted_config_account = auth.IdentityProperty(indexed=False)
59 62
60 63
61 ################################################################################ 64 ################################################################################
62 # Config parsing 65 # Config parsing
63 66
64 67
65 class ConfigFormatError(Exception): 68 class ConfigFormatError(Exception):
66 """A config file is malformed.""" 69 """A config file is malformed."""
67 70
68 71
(...skipping 17 matching lines...) Expand all
86 return msg 89 return msg
87 90
88 91
89 ################################################################################ 92 ################################################################################
90 # Rest 93 # Rest
91 94
92 95
93 @utils.cache 96 @utils.cache
94 def self_config_set(): 97 def self_config_set():
95 return 'services/%s' % app_identity.get_application_id() 98 return 'services/%s' % app_identity.get_application_id()
OLDNEW
« no previous file with comments | « no previous file | appengine/components/components/config/endpoint.py » ('j') | appengine/config_service/acl.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698