Skip to content

Commit d534683

Browse files
author
Rebecka Gulliksson
committed
Custom attribute release should be per IdP per SP.
Include custom attribute release under IdP entity id to be able to have custom release rules per IdP per SP.
1 parent b7fb789 commit d534683

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

doc/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,14 +242,16 @@ restrict the attribute release with the `custom_attribute_release` configuration
242242

243243
To exclude any attribute, just include its friendly name in the exclude list per SP.
244244

245-
In the following example the given name is never released to the SP with entity id `"sp-entity-id1"`:
245+
In the following example the given name is never released from the IdP with entity id `"idp-entity-id1"` to the SP
246+
with entity id `"sp-entity-id1"`:
246247

247248
```yaml
248249
config:
249250
config: [...]
250251
custom_attribute_release:
251-
sp-entity-id1:
252-
exclude: ["givenName"]
252+
idp-entity-id1
253+
sp-entity-id1:
254+
exclude: ["givenName"]
253255
254256
255257
#### Backend

src/satosa/frontends/saml2.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def __init__(self, auth_req_callback_func, internal_attributes, conf, base_url,
6868
self.config = conf
6969
self.endpoints = conf["endpoints"]
7070
self.acr_mapping = conf.get("acr_mapping")
71-
self.custom_attributes = conf.get("custom_attribute_release")
71+
self.custom_attribute_release = conf.get("custom_attribute_release")
7272
self.attribute_profile = conf.get("attribute_profile", "saml")
7373
self.idp = None
7474

@@ -254,9 +254,10 @@ def _handle_authn_response(self, context, internal_response, idp):
254254
else:
255255
auth_info["class_ref"] = internal_response.auth_info.auth_class_ref
256256

257-
if self.custom_attributes:
258-
custom_attributes = self.custom_attributes.get(resp_args["sp_entity_id"], {})
259-
attributes_to_remove = custom_attributes.get("exclude", [])
257+
if self.custom_attribute_release:
258+
custom_release_per_idp = self.custom_attribute_release.get(internal_response.auth_info.issuer, {})
259+
custom_release = custom_release_per_idp.get(resp_args["sp_entity_id"], {})
260+
attributes_to_remove = custom_release.get("exclude", [])
260261
for k in attributes_to_remove:
261262
ava.pop(k, None)
262263

tests/satosa/frontends/test_saml2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ def test_custom_attribute_release_with_less_attributes_than_entity_category(self
314314
user_attributes = {k: "foo" for k in expected_attributes}
315315
internal_response.attributes = AttributeMapper(internal_attributes).to_internal("saml", user_attributes)
316316

317-
custom_attributes = {sp_conf["entityid"]: {"exclude": ["norEduPersonNIN"]}}
317+
custom_attributes = {idp_conf["entityid"]: {sp_conf["entityid"]: {"exclude": ["norEduPersonNIN"]}}}
318318
samlfrontend = self.setup_for_authn_req(context, idp_conf, sp_conf, internal_attributes=internal_attributes,
319319
extra_config=dict(custom_attribute_release=custom_attributes))
320320

0 commit comments

Comments
 (0)