fix crash when user ID attribute is missing from reply #484
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If one of the attributes mentionned in user_id_from_attrs is missing from the IdP answer, SATOSA will crash with the following exception (missing attribute is called sub in this specific case):
[2025-01-10 10:16:08,259] [ERROR] [satosa.proxy_server.call] Unknown error
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/satosa/base.py", line 268, in run
resp = self._run_bound_endpoint(context, spec)
File "/usr/local/lib/python3.9/site-packages/satosa/base.py", line 193, in _run_bound_endpoint
return spec(context)
File "/usr/local/lib/python3.9/site-packages/satosa/backends/saml2.py", line 482, in authn_response
return self.auth_callback_func(context, self._translate_response(authn_response, context.state))
File "/usr/local/lib/python3.9/site-packages/satosa/base.py", line 154, in _auth_resp_callback_func
subject_id = ""
File "/usr/local/lib/python3.9/site-packages/satosa/base.py", line 155, in
for attr in self.config["INTERNAL_ATTRIBUTES"]["user_id_from_attrs"]:
KeyError: 'sub'
This PR fixes this issue by ensuring missing attributes are skipped.