@@ -56,6 +56,19 @@ def config_schema() -> Schema:
56
56
}
57
57
})
58
58
59
+ def connector_schema () -> Schema :
60
+ from schema import And , Optional , Or , Regex
61
+ return Schema ({
62
+ 'host' : str ,
63
+ Or ('integration_key' , 'secure_integration_key' ): str ,
64
+ 'admin_email' : str ,
65
+ Optional ('create_users' ): Optional (bool ),
66
+ Optional ('deactivate_users' ): Optional (bool ),
67
+ Optional ('exclusions' ): {
68
+ Optional ('groups' ): list ,
69
+ Optional ('users' ): list ,
70
+ }
71
+ })
59
72
60
73
class SignConfigLoader (ConfigLoader ):
61
74
"""
@@ -96,7 +109,7 @@ def __init__(self, args: dict):
96
109
filename , encoding = self ._config_file_info ()
97
110
self .config_loader = ConfigFileLoader (encoding , self .ROOT_CONFIG_PATH_KEYS , self .SUB_CONFIG_PATH_KEYS )
98
111
self .raw_config = self ._load_raw_config (filename , encoding )
99
- self ._validate (self .raw_config )
112
+ self ._validate (config_schema , self .raw_config )
100
113
self .main_config = self .load_main_config (filename , self .raw_config )
101
114
self .invocation_options = self .load_invocation_options ()
102
115
self .directory_groups = self .load_directory_groups ()
@@ -143,10 +156,10 @@ def _load_raw_config(self, filename, encoding) -> dict:
143
156
return self .config_loader .load_root_config (filename )
144
157
145
158
@staticmethod
146
- def _validate (raw_config : dict ):
159
+ def _validate (schm , raw_config : dict ):
147
160
from schema import SchemaError
148
161
try :
149
- config_schema ().validate (raw_config )
162
+ schm ().validate (raw_config )
150
163
except SchemaError as e :
151
164
raise ConfigValidationError (e .code ) from e
152
165
@@ -211,11 +224,14 @@ def get_target_options(self) -> dict[str, dict]:
211
224
if self .DEFAULT_ORG_NAME not in target_configs :
212
225
raise AssertionException (f"'sign_orgs' config must specify a connector with '{ self .DEFAULT_ORG_NAME } ' key" )
213
226
primary_options = self .config_loader .load_sub_config (target_configs [self .DEFAULT_ORG_NAME ])
227
+ self ._validate (connector_schema , primary_options )
214
228
all_options = {}
215
229
for target_id , config_file in target_configs .items ():
216
230
if target_id == self .DEFAULT_ORG_NAME :
217
231
continue
218
- all_options [target_id ] = self .config_loader .load_sub_config (config_file )
232
+ cfg = self .config_loader .load_sub_config (config_file )
233
+ self ._validate (connector_schema , cfg )
234
+ all_options [target_id ] = cfg
219
235
all_options [self .DEFAULT_ORG_NAME ] = primary_options
220
236
return all_options
221
237
0 commit comments