Skip to content

impossible to use embedded certs when signing is required #32

@anthonyrisinger

Description

@anthonyrisinger

when using embedded certs (certs contained within the settings dictionary... ie. NO external files whatsoever) it's not possible to enable signatures of any kind.

__load_settings_from_dict (also called by __load_settings_from_file) tries to check settings:
https://github.com/onelogin/python-saml/blob/master/src/onelogin/saml2/settings.py#L194

which tries to ensure certs are available:
https://github.com/onelogin/python-saml/blob/master/src/onelogin/saml2/settings.py#L373

which interacts with self.__sp:
https://github.com/onelogin/python-saml/blob/master/src/onelogin/saml2/settings.py#L441
https://github.com/onelogin/python-saml/blob/master/src/onelogin/saml2/settings.py#L461

but that hasn't been set yet! (note the lineno of the first step):
https://github.com/onelogin/python-saml/blob/master/src/onelogin/saml2/settings.py#L197

check_sp_certs(...), get_sp_key(...), and get_sp_cert(...) should either accept an sp argument and fallback to self.__sp or self.__sp must be set earlier.

this can be worked around in a disgusting way (sadly made more disgusting due to excessive use of __ prefix, we don't do this in python!):

def get_saml_auth(request_data, settings_dict):
    """
    Wrapper to handle buggy saml object init
    """
    # drop security info so objects can initialize
    security = settings_dict.pop('security')
    auth = OneLogin_Saml2_Auth(request_data, settings_dict)
    settings = OneLogin_Saml2_Settings(settings_dict)

    # reinstate security info, prime object, reload from dict
    settings_dict['security'] = security
    settings._OneLogin_Saml2_Settings__sp = settings_dict['sp']
    settings._OneLogin_Saml2_Settings__load_settings_from_dict(settings_dict)

    # assign new internal settings object
    auth._OneLogin_Saml2_Auth__settings = settings
    return auth

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions