Skip to content

Commit 30b872f

Browse files
committed
Remove attribute hashing
Signed-off-by: Ivan Kanakarakis <[email protected]>
1 parent c5b4e80 commit 30b872f

File tree

2 files changed

+1
-39
lines changed

2 files changed

+1
-39
lines changed

src/satosa/base.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from .context import Context
1414
from .exception import SATOSAConfigurationError
1515
from .exception import SATOSAError, SATOSAAuthenticationError, SATOSAUnknownError
16-
from .internal_data import UserIdHasher
1716
from .logging_util import satosa_logging
1817
from .micro_services.account_linking import AccountLinking
1918
from .micro_services.consent import Consent
@@ -119,7 +118,6 @@ def _auth_req_callback_func(self, context, internal_request):
119118
satosa_logging(logger, logging.INFO,
120119
"Requesting provider: {}".format(internal_request.requester), state)
121120

122-
UserIdHasher.save_state(internal_request, state)
123121
if self.request_micro_services:
124122
return self.request_micro_services[0].process(context, internal_request)
125123

@@ -131,15 +129,6 @@ def _auth_req_finish(self, context, internal_request):
131129
return backend.start_auth(context, internal_request)
132130

133131
def _auth_resp_finish(self, context, internal_response):
134-
# re-hash user id since e.g. account linking micro service might have changed it
135-
user_id = UserIdHasher.hash_id(
136-
self.config["USER_ID_HASH_SALT"],
137-
internal_response.user_id,
138-
internal_response.requester,
139-
context.state)
140-
internal_response.user_id = user_id
141-
internal_response.user_id_hash_type = UserIdHasher.hash_type(
142-
context.state)
143132
user_id_to_attr = self.config["INTERNAL_ATTRIBUTES"].get("user_id_to_attr", None)
144133
if user_id_to_attr:
145134
internal_response.attributes[user_id_to_attr] = [internal_response.user_id]
@@ -187,20 +176,6 @@ def _auth_resp_callback_func(self, context, internal_response):
187176
]
188177
internal_response.user_id = "".join(user_id)
189178

190-
# The authentication response may not contain a user id. For example
191-
# a SAML IdP may not assert a SAML NameID in the subject and we may
192-
# not be configured to construct one from asserted attributes.
193-
# So only hash the user_id if it is not None.
194-
if internal_response.user_id:
195-
user_id = UserIdHasher.hash_id(
196-
self.config["USER_ID_HASH_SALT"],
197-
internal_response.user_id,
198-
internal_response.requester,
199-
context.state)
200-
internal_response.user_id = user_id
201-
internal_response.user_id_hash_type = UserIdHasher.hash_type(
202-
context.state)
203-
204179
if self.response_micro_services:
205180
return self.response_micro_services[0].process(
206181
context, internal_response)

tests/satosa/test_base.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from satosa import util
1111
from satosa.base import SATOSABase
1212
from satosa.exception import SATOSAConfigurationError
13-
from satosa.internal_data import InternalResponse, AuthenticationInformation, UserIdHasher, InternalRequest
13+
from satosa.internal_data import InternalResponse, AuthenticationInformation, InternalRequest
1414
from satosa.micro_services import consent
1515
from satosa.satosa_config import SATOSAConfig
1616

@@ -49,21 +49,10 @@ def test_auth_resp_callback_func_user_id_from_attrs_is_used_to_override_user_id(
4949
internal_resp.requester = "test_requester"
5050
context.state[satosa.base.STATE_KEY] = {"requester": "test_requester"}
5151
context.state[satosa.routing.STATE_KEY] = satosa_config["FRONTEND_MODULES"][0]["name"]
52-
UserIdHasher.save_state(InternalRequest(NAMEID_FORMAT_PERSISTENT, ""), context.state)
5352

5453
base._auth_resp_callback_func(context, internal_resp)
5554

5655
expected_user_id = "[email protected]"
57-
expected_user_id = UserIdHasher.hash_id(
58-
satosa_config["USER_ID_HASH_SALT"],
59-
expected_user_id,
60-
internal_resp.requester,
61-
context.state)
62-
expected_user_id = UserIdHasher.hash_id(
63-
satosa_config["USER_ID_HASH_SALT"],
64-
expected_user_id,
65-
internal_resp.requester,
66-
context.state)
6756
assert internal_resp.user_id == expected_user_id
6857

6958
def test_auth_req_callback_stores_state_for_consent(self, context, satosa_config):
@@ -86,7 +75,6 @@ def test_auth_resp_callback_func_hashes_all_specified_attributes(self, context,
8675
internal_resp = InternalResponse(AuthenticationInformation("", "", ""))
8776
internal_resp.attributes = copy.copy(attributes)
8877
internal_resp.user_id = "test_user"
89-
UserIdHasher.save_state(InternalRequest(NAMEID_FORMAT_TRANSIENT, ""), context.state)
9078
context.state[satosa.base.STATE_KEY] = {"requester": "test_requester"}
9179
context.state[satosa.routing.STATE_KEY] = satosa_config["FRONTEND_MODULES"][0]["name"]
9280

@@ -105,7 +93,6 @@ def test_auth_resp_callback_func_respects_user_id_to_attr(self, context, satosa_
10593
internal_resp.user_id = "user1234"
10694
context.state[satosa.base.STATE_KEY] = {"requester": "test_requester"}
10795
context.state[satosa.routing.STATE_KEY] = satosa_config["FRONTEND_MODULES"][0]["name"]
108-
UserIdHasher.save_state(InternalRequest(NAMEID_FORMAT_TRANSIENT, ""), context.state)
10996

11097
base._auth_resp_callback_func(context, internal_resp)
11198
assert internal_resp.attributes["user_id"] == [internal_resp.user_id]

0 commit comments

Comments
 (0)