Skip to content

Commit d1f3ef5

Browse files
committed
fix for bad config check on sensitive keys
1 parent adf78af commit d1f3ef5

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/satosa/satosa_config.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class SATOSAConfig(object):
1818
"""
1919
sensitive_dict_keys = ["STATE_ENCRYPTION_KEY", "USER_ID_HASH_SALT"]
2020
mandatory_dict_keys = ["BASE", "BACKEND_MODULES", "FRONTEND_MODULES",
21-
"INTERNAL_ATTRIBUTES", "COOKIE_STATE_NAME"] + sensitive_dict_keys
21+
"INTERNAL_ATTRIBUTES", "COOKIE_STATE_NAME"]
2222

2323
def __init__(self, config):
2424
"""
@@ -83,6 +83,10 @@ def _verify_dict(self, conf):
8383
if key not in conf:
8484
raise SATOSAConfigurationError("Missing key '%s' in config" % key)
8585

86+
for key in SATOSAConfig.sensitive_dict_keys:
87+
if key not in conf and "SATOSA_{key}".format(key=key) not in os.environ:
88+
raise SATOSAConfigurationError("Missing key '%s' from config and ENVIRONMENT" % key)
89+
8690
def __getitem__(self, item):
8791
"""
8892
Returns data bound to the key 'item'.

tests/satosa/test_satosa_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,4 @@ def test_can_read_endpoint_configs_from_file(self, satosa_config_dict, modules_k
7777
satosa_config_dict[modules_key] = ["/fake_file_path"]
7878

7979
with pytest.raises(SATOSAConfigurationError):
80-
SATOSAConfig(satosa_config_dict)
80+
SATOSAConfig(satosa_config_dict)

0 commit comments

Comments
 (0)