Skip to content

Commit b8c5545

Browse files
committed
Add CO attribute scope to state for SAMLVirtualCoFrontend
Add logic to store the configured CO attribute scope for an instance of SAMLVirtualCoFrontend in the state so that microservices can easily access it.
1 parent 1e39a0d commit b8c5545

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/satosa/frontends/saml2.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,7 @@ class SAMLVirtualCoFrontend(SAMLFrontend):
702702
KEY_CO_NAME = 'co_name'
703703
KEY_CO_ENTITY_ID = 'co_entity_id'
704704
KEY_CO_ATTRIBUTES = 'co_static_saml_attributes'
705+
KEY_CO_ATTRIBUTE_SCOPE = 'co_attribute_scope'
705706
KEY_CONTACT_PERSON = 'contact_person'
706707
KEY_ENCODEABLE_NAME = 'encodeable_name'
707708
KEY_ORGANIZATION = 'organization'
@@ -774,6 +775,11 @@ def _create_state_data(self, context, resp_args, relay_state):
774775
state[self.KEY_CO_ENTITY_ID] = context.get_decoration(
775776
self.KEY_CO_ENTITY_ID)
776777

778+
co_config = self._get_co_config(context)
779+
state[self.KEY_CO_ATTRIBUTE_SCOPE] = co_config.get(
780+
self.KEY_CO_ATTRIBUTE_SCOPE,
781+
None)
782+
777783
return state
778784

779785
def _get_co_config(self, context):

tests/satosa/frontends/test_saml2.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,7 @@ class TestSAMLVirtualCoFrontend(TestSAMLFrontend):
412412
CO_C = "countryname"
413413
CO_CO = "friendlycountryname"
414414
CO_NOREDUORGACRONYM = "noreduorgacronym"
415+
CO_SCOPE = "messproject.org"
415416
CO_STATIC_SAML_ATTRIBUTES = {
416417
CO_O: ["Medium Energy Synchrotron Source"],
417418
CO_C: ["US"],
@@ -438,7 +439,8 @@ def frontend(self, idp_conf, sp_conf):
438439
# SAML attributes so their presence in a SAML Response can be tested.
439440
collab_org = {
440441
"encodeable_name": self.CO,
441-
"co_static_saml_attributes": self.CO_STATIC_SAML_ATTRIBUTES
442+
"co_static_saml_attributes": self.CO_STATIC_SAML_ATTRIBUTES,
443+
"co_attribute_scope": self.CO_SCOPE
442444
}
443445

444446
# Use the dynamically updated idp_conf fixture, the configured
@@ -491,6 +493,8 @@ def test_create_state_data(self, frontend, context, idp_conf):
491493
expected_entityid = "{}/{}".format(idp_conf['entityid'], self.CO)
492494
assert state[frontend.KEY_CO_ENTITY_ID] == expected_entityid
493495

496+
assert state[frontend.KEY_CO_ATTRIBUTE_SCOPE] == self.CO_SCOPE
497+
494498
def test_get_co_name(self, frontend, context):
495499
co_name = frontend._get_co_name(context)
496500
assert co_name == self.CO

0 commit comments

Comments
 (0)