Skip to content

Unsolicited Response: KeyError exception when allow_unsolicited = true #330

Open
@senorkrabs

Description

@senorkrabs

Code Version

latest (6.1.0)

Expected Behavior

I'm working with an SP that does not support sp-initiated requests. Ideally, I would like to use do something like:
SAMLFrontend Idp-initated request (specifying Target SP) > SAMLBackend > Target IdP (shibboleth) > SAMLBackend > SAMLFrontend > SP ACS with RelayState=https://some.target.url

Based on the docs, it doesn't appear that Satosa/pysaml2 have a way of supporting this, so I'm trying to enable unsolicited responses to the SAMLBackend and do this instead:
Target IdP (shibboleth) Idp-initiated request with RelayState=https://some.target.url > SAMLBackend > SAMLFrontEnd > SP ACS with RelayState=https://some.target.url

Note: I'm not sure if using unsolicited responses from the SP will work, since I'll need a way to tell the SAMLFrontend what SP to response to. I'm open to other approaches, but the SP supporting sp-initiated auth is not an option at this time.

Current Behavior

After receiving the assertion from the Target IdP, Satosa throws the following error:

[2020-05-28 14:14:56,291] [ERROR] [satosa.base.run] [urn:uuid:8a8edc2a-7daa-43e6-ae00-83bd82a1b33f] Uncaught exception
Traceback (most recent call last):
  File "/src/satosa/src/satosa/base.py", line 240, in run
    resp = self._run_bound_endpoint(context, spec)
  File "/src/satosa/src/satosa/base.py", line 180, in _run_bound_endpoint
    return spec(context)
  File "/src/satosa/src/satosa/backends/saml2.py", line 340, in authn_response
    if context.state[self.name]["relay_state"] != context.request["RelayState"]:
  File "/usr/lib/python3.7/collections/__init__.py", line 1025, in __getitem__
    raise KeyError(key)
KeyError: 'Saml2'
[2020-05-28 14:14:56,293] [ERROR] [satosa.proxy_server.__call__] Unknown error
Traceback (most recent call last):
  File "/src/satosa/src/satosa/base.py", line 240, in run
    resp = self._run_bound_endpoint(context, spec)
  File "/src/satosa/src/satosa/base.py", line 180, in _run_bound_endpoint
    return spec(context)
  File "/src/satosa/src/satosa/backends/saml2.py", line 340, in authn_response
    if context.state[self.name]["relay_state"] != context.request["RelayState"]:
  File "/usr/lib/python3.7/collections/__init__.py", line 1025, in __getitem__
    raise KeyError(key)
KeyError: 'Saml2'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/src/satosa/src/satosa/proxy_server.py", line 118, in __call__
    resp = self.run(context)
  File "/src/satosa/src/satosa/base.py", line 258, in run
    raise SATOSAUnknownError("Unknown error") from err
satosa.exception.SATOSAUnknownError: Unknown error

Possible Solution

I believe the SAMLBackend is attempting to compare a stored RelayState value that doesn't exist because the response was unsolicited.

Steps to Reproduce

  1. Send an unsolicited response to SAMLBackend

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions