Skip to content

Commit 5a2122e

Browse files
committed
This commit contains:
- Removed xmldoc from spidsaml2's class scope because it's not useful. - Removed useful comments - Moved method comments inside it
1 parent 74a223c commit 5a2122e

2 files changed

Lines changed: 16 additions & 93 deletions

File tree

iam-proxy-italia-project/backends/ciesaml2.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -510,15 +510,16 @@ def authn_response(self, context, binding):
510510
context, self._translate_response(authn_response, context.state)
511511
)
512512

513-
"""
514-
method __create_metadata private
515-
Create metadata for CieSAMLBackend
516513

517-
:param self: Instance for CieSAMLBackend
518-
:param conf: Configuration for CieSAMLBackend
519-
:return: xmldoc
520-
"""
521514
def __create_metadata(self, conf):
515+
"""
516+
method __create_metadata private
517+
Create metadata for CieSAMLBackend
518+
519+
:param self: Instance for CieSAMLBackend
520+
:param conf: Configuration for CieSAMLBackend
521+
:return: xmldoc
522+
"""
522523
logger.debug(f"Entering method: {inspect.getframeinfo(inspect.currentframe()).function}. Params [conf: {conf}].")
523524
metadata = entity_descriptor(conf)
524525

iam-proxy-italia-project/backends/spidsaml2.py

Lines changed: 8 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@ class SpidSAMLBackend(SAMLBackend):
7979

8080
_authn_context = "https://www.spid.gov.it/SpidL1"
8181

82-
xmldoc = None
83-
8482
def __init__(self, *args, **kwargs):
8583
logger.debug(f"Initializing: {self.__class__.__name__}. Params[args: {args}, kwargs: {kwargs}]")
8684
super().__init__(*args, **kwargs)
@@ -232,82 +230,6 @@ def _metadata_endpoint(self, context):
232230
:return: response with metadata
233231
"""
234232
logger.debug("Sending metadata response")
235-
'''
236-
237-
DEPRECATED:
238-
239-
240-
conf = self.sp.config
241-
242-
if not self.xmldoc:
243-
logger.debug("inizializing metadata xmldoc")
244-
self.xmldoc = self.create_metadata(conf)
245-
246-
logger.debug(f"Created metadata xmldoc: {self.xmldoc}")
247-
248-
249-
metadata = entity_descriptor(conf)
250-
251-
# creare gli attribute_consuming_service
252-
metadata.spsso_descriptor.attribute_consuming_service[0].index = '0'
253-
metadata.spsso_descriptor.attribute_consuming_service[0].service_name[0].lang = "it"
254-
metadata.spsso_descriptor.attribute_consuming_service[0].service_name[0].text = metadata.entity_id
255-
for reqattr in metadata.spsso_descriptor.attribute_consuming_service[0].requested_attribute:
256-
reqattr.name_format = None
257-
reqattr.friendly_name = None
258-
259-
metadata.spsso_descriptor.assertion_consumer_service[0].index = '0'
260-
metadata.spsso_descriptor.assertion_consumer_service[0].is_default = 'true'
261-
262-
if self.config["sp_config"]["ficep_enable"] is True:
263-
# Aggiungere CIE 99
264-
metadata.spsso_descriptor.attribute_consuming_service.append(saml2.md.AttributeConsumingService())
265-
metadata.spsso_descriptor.attribute_consuming_service[1].index = '99'
266-
metadata.spsso_descriptor.attribute_consuming_service[1].service_name.append(saml2.md.ServiceName())
267-
metadata.spsso_descriptor.attribute_consuming_service[1].service_name[0].lang = "it"
268-
metadata.spsso_descriptor.attribute_consuming_service[1].service_name[0].text = "eIDAS Natural Person Minimum Attribute Set"
269-
metadata.spsso_descriptor.attribute_consuming_service[1].requested_attribute = [
270-
saml2.md.RequestedAttribute('true', None, 'spidCode'),
271-
saml2.md.RequestedAttribute('true', None, 'name'),
272-
saml2.md.RequestedAttribute('true', None, 'familyName'),
273-
saml2.md.RequestedAttribute('true', None, 'dateOfBirth'),
274-
]
275-
276-
metadata.spsso_descriptor.assertion_consumer_service[1].index = '99'
277-
metadata.spsso_descriptor.assertion_consumer_service[1].is_default = None
278-
279-
# Aggiungere CIE 100
280-
metadata.spsso_descriptor.attribute_consuming_service.append(saml2.md.AttributeConsumingService())
281-
metadata.spsso_descriptor.attribute_consuming_service[2].index = '100'
282-
metadata.spsso_descriptor.attribute_consuming_service[2].service_name.append(saml2.md.ServiceName())
283-
metadata.spsso_descriptor.attribute_consuming_service[2].service_name[0].lang = "it"
284-
metadata.spsso_descriptor.attribute_consuming_service[2].service_name[0].text = "eIDAS Natural Person Full Attribute Set"
285-
metadata.spsso_descriptor.attribute_consuming_service[2].requested_attribute = [
286-
saml2.md.RequestedAttribute('true', None, 'spidCode'),
287-
saml2.md.RequestedAttribute('true', None, 'name'),
288-
saml2.md.RequestedAttribute('true', None, 'familyName'),
289-
saml2.md.RequestedAttribute('true', None, 'dateOfBirth'),
290-
saml2.md.RequestedAttribute('true', None, 'placeOfBirth'),
291-
saml2.md.RequestedAttribute('true', None, 'address'),
292-
saml2.md.RequestedAttribute('true', None, 'gender'),
293-
]
294-
295-
metadata.spsso_descriptor.assertion_consumer_service[2].index = '100'
296-
metadata.spsso_descriptor.assertion_consumer_service[2].is_default = None
297-
298-
# load ContactPerson Extensions
299-
self._metadata_contact_person(metadata, conf)
300-
301-
# metadata signature
302-
secc = security_context(conf)
303-
#
304-
sign_dig_algs = self.get_kwargs_sign_dig_algs()
305-
eid, xmldoc = sign_entity_descriptor(
306-
metadata, None, secc, **sign_dig_algs)
307-
308-
valid_instance(eid)
309-
310-
'''
311233
return Response(
312234
text_type(self.xmldoc).encode("utf-8"), content="text/xml; charset=utf8"
313235
)
@@ -668,15 +590,15 @@ def authn_response(self, context, binding):
668590
context, self._translate_response(authn_response, context.state)
669591
)
670592

671-
"""
672-
method __create_metadata private
673-
Create metadata for SpidSaml2
674-
675-
:param self: Instance for SpidSaml2
676-
:param conf: Configuration for SpidSaml2
677-
:return: xmldoc
678-
"""
679593
def __create_metadata(self, conf):
594+
"""
595+
method __create_metadata private
596+
Create metadata for SpidSaml2
597+
598+
:param self: Instance for SpidSaml2
599+
:param conf: Configuration for SpidSaml2
600+
:return: xmldoc
601+
"""
680602
logger.debug(f"Entering method: {inspect.getframeinfo(inspect.currentframe()).function}. Params [conf: {conf}]")
681603
metadata = entity_descriptor(conf)
682604

0 commit comments

Comments
 (0)