Skip to content

Commit 831a8a6

Browse files
committed
Deprecate USER_ID_HASH_SALT configuration option
Signed-off-by: Ivan Kanakarakis <[email protected]>
1 parent 30b872f commit 831a8a6

File tree

6 files changed

+17
-12
lines changed

6 files changed

+17
-12
lines changed

doc/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ in the [example directory](../example).
4343
| `BACKEND_MODULES` | string[] | `[openid_connect_backend.yaml, saml2_backend.yaml]` | list of plugin configuration file paths, describing enabled backends |
4444
| `FRONTEND_MODULES` | string[] | `[saml2_frontend.yaml, openid_connect_frontend.yaml]` | list of plugin configuration file paths, describing enabled frontends |
4545
| `MICRO_SERVICES` | string[] | `[statistics_service.yaml]` | list of plugin configuration file paths, describing enabled microservices |
46-
| `USER_ID_HASH_SALT` | string | `61a89d2db0b9e1e2` | salt used when creating the persistent user identifier, will be overriden by the environment variable `SATOSA_USER_ID_HASH_SALT` if it is set |
46+
| `USER_ID_HASH_SALT` | string | `61a89d2db0b9e1e2` | **DEPRECATED - use the hasher micro-service** salt used when creating the persistent user identifier, will be overriden by the environment variable `SATOSA_USER_ID_HASH_SALT` if it is set |
4747
| `LOGGING` | dict | see [Python logging.conf](https://docs.python.org/3/library/logging.config.html) | optional configuration of application logging |
4848

4949

@@ -410,7 +410,7 @@ which should be used when configuring the attribute mapping (see above).
410410
### Ping frontend for simple heartbeat monitoring
411411

412412
The ping frontend responds to a query with a simple
413-
200 OK and is intended to be used as a simple heartbeat monitor,
413+
200 OK and is intended to be used as a simple heartbeat monitor,
414414
for example by a load balancer. The default configuration file can
415415
be found [here](../example/plugins/frontends/ping_frontend.yaml.example).
416416

@@ -581,7 +581,7 @@ The SATOSA proxy is a Python WSGI application and so may be run using any WSGI c
581581

582582
Gunicorn 'Green Unicorn' is a Python WSGI HTTP Server for UNIX and is the server used most often
583583
to run the proxy. In a production deployment the Gunicorn server is often proxied by a
584-
full featured general purpose web server (in a reverse proxy architecture) such as Nginx or
584+
full featured general purpose web server (in a reverse proxy architecture) such as Nginx or
585585
Apache HTTP Server to help buffer slow clients and enable more sophisticated error page rendering.
586586

587587
Start the proxy server with the following command:

example/proxy_conf.yaml.example

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ FRONTEND_MODULES:
1313
- "plugins/frontends/saml2_frontend.yaml"
1414
MICRO_SERVICES:
1515
- "plugins/microservices/static_attributes.yaml"
16-
USER_ID_HASH_SALT: "61a89d2db0b9e1e27d490d050b478fe71f352fddd3528a44157f43e339c6c62f2362fb413179937d96172bf84233317"
1716
LOGGING:
1817
version: 1
1918
formatters:
@@ -40,4 +39,4 @@ LOGGING:
4039
propagate: no
4140
root:
4241
level: INFO
43-
handlers: [info_file_handler]
42+
handlers: [info_file_handler]

src/satosa/base.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import json
55
import logging
66
import uuid
7+
import warnings as _warnings
78

89
from saml2.s_utils import UnknownSystemEntity
910

@@ -22,6 +23,8 @@
2223
from .state import cookie_to_state, SATOSAStateError, State, state_to_cookie
2324

2425

26+
_warnings.simplefilter("default")
27+
2528
logger = logging.getLogger(__name__)
2629

2730
STATE_KEY = "SATOSA_BASE"
@@ -41,6 +44,15 @@ def __init__(self, config):
4144
:param config: satosa proxy config
4245
"""
4346
self.config = config
47+
48+
for option in ["USER_ID_HASH_SALT"]:
49+
if option in self.config:
50+
msg = (
51+
"'{opt}' configuration option is deprecated."
52+
" Use the hasher microservice instead."
53+
).format(opt=option)
54+
_warnings.warn(msg, DeprecationWarning)
55+
4456
logger.info("Loading backend modules...")
4557
backends = load_backends(self.config, self._auth_resp_callback_func,
4658
self.config["INTERNAL_ATTRIBUTES"])

tests/conftest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ def satosa_config_dict(backend_plugin_config, frontend_plugin_config, request_mi
134134
"FRONTEND_MODULES": ["bar"],
135135
"INTERNAL_ATTRIBUTES": {"attributes": {}},
136136
"STATE_ENCRYPTION_KEY": "state_encryption_key",
137-
"USER_ID_HASH_SALT": "user_id_hash_salt",
138137
"CUSTOM_PLUGIN_MODULE_PATHS": [os.path.dirname(__file__)],
139138
"BACKEND_MODULES": [backend_plugin_config],
140139
"FRONTEND_MODULES": [frontend_plugin_config],

tests/satosa/test_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def test_auth_resp_callback_func_hashes_all_specified_attributes(self, context,
8181
base._auth_resp_callback_func(context, internal_resp)
8282
for attr in satosa_config["INTERNAL_ATTRIBUTES"]["hash"]:
8383
assert internal_resp.attributes[attr] == [
84-
util.hash_data(satosa_config["USER_ID_HASH_SALT"], v)
84+
util.hash_data(satosa_config.get("USER_ID_HASH_SALT", ""), v)
8585
for v in attributes[attr]
8686
]
8787

tests/satosa/test_satosa_config.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,15 @@ def non_sensitive_config_dict(self):
2222
return config
2323

2424
def test_read_senstive_config_data_from_env_var(self, monkeypatch, non_sensitive_config_dict):
25-
monkeypatch.setenv("SATOSA_USER_ID_HASH_SALT", "user_id_hash_salt")
2625
monkeypatch.setenv("SATOSA_STATE_ENCRYPTION_KEY", "state_encryption_key")
2726
config = SATOSAConfig(non_sensitive_config_dict)
28-
assert config["USER_ID_HASH_SALT"] == "user_id_hash_salt"
2927
assert config["STATE_ENCRYPTION_KEY"] == "state_encryption_key"
3028

3129
def test_senstive_config_data_from_env_var_overrides_config(self, monkeypatch, non_sensitive_config_dict):
32-
non_sensitive_config_dict["USER_ID_HASH_SALT"] = "foo"
3330
non_sensitive_config_dict["STATE_ENCRYPTION_KEY"] = "bar"
34-
monkeypatch.setenv("SATOSA_USER_ID_HASH_SALT", "user_id_hash_salt")
3531
monkeypatch.setenv("SATOSA_STATE_ENCRYPTION_KEY", "state_encryption_key")
3632

3733
config = SATOSAConfig(non_sensitive_config_dict)
38-
assert config["USER_ID_HASH_SALT"] == "user_id_hash_salt"
3934
assert config["STATE_ENCRYPTION_KEY"] == "state_encryption_key"
4035

4136
def test_constructor_should_raise_exception_if_sensitive_keys_are_missing(self, non_sensitive_config_dict):

0 commit comments

Comments
 (0)