SAML-Toolkits / python3-saml

MIT License
671 stars 302 forks source link

get_session_expiration and get_last_assertion_not_on_or_after return None #322

Closed shaozi closed 1 year ago

shaozi commented 1 year ago

The methods get_session_expiration and get_last_assertion_not_on_or_after of OneLogin_Saml2_Auth returns None instead of the value in NotOnOrAfter:

auth = OneLogin_Saml2_Auth(
        req,
        custom_base_path='config',
)
auth.process_response(request_id=request_id)
if auth.is_authenticated():
        print(auth.get_session_expiration())
        print(auth.get_last_assertion_not_on_or_after())
kotofos commented 1 year ago

You probably should check for errors first

        errors = auth.get_errors()
        if errors:
            error_reason = auth.get_last_error_reason()
            raise ValueError(f'{error_reason} {"".join(errors)}')
pitbulk commented 1 year ago

@shaozi , as @kotofos suggested, those attributes are only available if the SAML Response was valid, if you are directly using the OneLogin_Saml2_Auth object.

See process_response