idp_metadata_parser.py

About this file

We attempted to read from templates/app_lib_onelogin_saml2_idp_metadata_parser.py_hw.txt but failed.

Code Check Report


app/lib/onelogin/saml2/idp_metadata_parser.py:35:121: E501 line too long (132 > 120 characters)
app/lib/onelogin/saml2/idp_metadata_parser.py:58:13: E722 do not use bare 'except'
app/lib/onelogin/saml2/idp_metadata_parser.py:73:121: E501 line too long (132 > 120 characters)
app/lib/onelogin/saml2/idp_metadata_parser.py:165:121: E501 line too long (176 > 120 characters)
app/lib/onelogin/saml2/idp_metadata_parser.py:166:121: E501 line too long (176 > 120 characters)
                        

Documentation drawn from source code

OneLogin_Saml2_IdPMetadataParser class
Copyright (c) 2010-2018 OneLogin, Inc.
MIT License
Metadata class of OneLogin's Python Toolkit.


OneLogin_Saml2_IdPMetadataParser(object):

A class that contain methods related to obtaining and parsing metadata from IdP

get_metadata(url, validate_cert=True):

Gets the metadata XML from the provided URL
:param url: Url where the XML of the Identity Provider Metadata is published.
:type url: string

:param validate_cert: If the url uses https schema, that flag enables or not the verification of the associated certificate.
:type validate_cert: bool

:returns: metadata XML
:rtype: string

parse_remote(url, validate_cert=True, entity_id=None, **kwargs):

Gets the metadata XML from the provided URL and parse it, returning a dict with extracted data
:param url: Url where the XML of the Identity Provider Metadata is published.
:type url: string

:param validate_cert: If the url uses https schema, that flag enables or not the verification of the associated certificate.
:type validate_cert: bool

:param entity_id: Specify the entity_id of the EntityDescriptor that you want to parse a XML
that contains multiple EntityDescriptor.
:type entity_id: string

:returns: settings dict with extracted data
:rtype: dict

parse(

Parses the Identity Provider metadata and return a dict with extracted data.

If there are multiple tags, parse only the first.

Parses only those SSO endpoints with the same binding as given by
the `required_sso_binding` parameter.

Parses only those SLO endpoints with the same binding as given by
the `required_slo_binding` parameter.

If the metadata specifies multiple SSO endpoints with the required
binding, extract only the first (the same holds true for SLO
endpoints).

:param idp_metadata: XML of the Identity Provider Metadata.
:type idp_metadata: string

:param required_sso_binding: Parse only POST or REDIRECT SSO endpoints.
:type required_sso_binding: one of OneLogin_Saml2_Constants.BINDING_HTTP_REDIRECT
or OneLogin_Saml2_Constants.BINDING_HTTP_POST

:param required_slo_binding: Parse only POST or REDIRECT SLO endpoints.
:type required_slo_binding: one of OneLogin_Saml2_Constants.BINDING_HTTP_REDIRECT
or OneLogin_Saml2_Constants.BINDING_HTTP_POST

:param entity_id: Specify the entity_id of the EntityDescriptor that you want to parse a XML
that contains multiple EntityDescriptor.
:type entity_id: string

:returns: settings dict with extracted data
:rtype: dict

merge_settings(settings, new_metadata_settings):

Will update the settings with the provided new settings data extracted from the IdP metadata
:param settings: Current settings dict data
:type settings: string
:param new_metadata_settings: Settings to be merged (extracted from IdP metadata after parsing)
:type new_metadata_settings: string
:returns: merged settings
:rtype: dict

dict_deep_merge(a, b, path=None):
Deep-merge dictionary `b` into dictionary `a`.

Kudos to http://stackoverflow.com/a/7205107/145400

Source code