djangosaml2idp icon indicating copy to clipboard operation
djangosaml2idp copied to clipboard

UnknownSystemEntity exception

Open shivshankardayal opened this issue 1 year ago • 3 comments

I am trying to implement SAML auth with Mautic(https://docs.mautic.org/en) as SP and my django app as IDP. I have added SP information using admin panel of Django app. However, when I try to login using IDP initiated login it gives me UnknownSystemEntity exception. How toresolve this? Given below is the stacktarce:

Traceback (most recent call last):
  File "/home/shiv/upwork/ryan/marketing-automation/mautic_dashboard/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/home/shiv/upwork/ryan/marketing-automation/mautic_dashboard/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/shiv/upwork/ryan/marketing-automation/mautic_dashboard/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 84, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/shiv/upwork/ryan/marketing-automation/mautic_dashboard/venv/lib/python3.10/site-packages/django/utils/decorators.py", line 46, in _wrapper
    return bound_method(*args, **kwargs)
  File "/home/shiv/upwork/ryan/marketing-automation/mautic_dashboard/venv/lib/python3.10/site-packages/django/views/decorators/cache.py", line 62, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/home/shiv/upwork/ryan/marketing-automation/mautic_dashboard/venv/lib/python3.10/site-packages/django/contrib/auth/mixins.py", line 73, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/home/shiv/upwork/ryan/marketing-automation/mautic_dashboard/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 119, in dispatch
    return handler(request, *args, **kwargs)
  File "/home/shiv/upwork/ryan/marketing-automation/mautic_dashboard/venv/lib/python3.10/site-packages/djangosaml2idp/views.py", line 299, in get
    binding_out, destination = idp_server.pick_binding(
  File "/home/shiv/upwork/ryan/marketing-automation/mautic_dashboard/venv/lib/python3.10/site-packages/saml2/entity.py", line 349, in pick_binding
    srvs = sfunc(entity_id, binding, descr_type)
  File "/home/shiv/upwork/ryan/marketing-automation/mautic_dashboard/venv/lib/python3.10/site-packages/saml2/mdstore.py", line 1311, in assertion_consumer_service
    return self.service(entity_id, "spsso_descriptor",
  File "/home/shiv/upwork/ryan/marketing-automation/mautic_dashboard/venv/lib/python3.10/site-packages/saml2/mdstore.py", line 1204, in service
    raise UnknownSystemEntity(entity_id)
saml2.s_utils.UnknownSystemEntity: http://127.0.0.1:81
[15/Jul/2022 09:14:28] "GET /idp/sso/init/?sp=http%3A%2F%2F127.0.0.1%3A81&RelayState=%2F HTTP/1.1" 500 109227

shivshankardayal avatar Jul 15 '22 09:07 shivshankardayal

It looks like it's not finding idp config for an idp with entity id: http://127.0.0.1:81/

lgarvey avatar Jul 15 '22 09:07 lgarvey

Given below is the IDP config:

'idp': {
            'name': 'Django localhost IdP',
            'endpoints': {
                'single_sign_on_service': [
                    ('http://localhost:8000/idp/sso/post/', saml2.BINDING_HTTP_POST),
                    ('http://localhost:8000/idp/sso/redirect/', saml2.BINDING_HTTP_REDIRECT),
                ],
                "single_logout_service": [
                    ("http://localhost:8000/idp/slo/post/", saml2.BINDING_HTTP_POST),
                    ("http://localhost:8000/idp/slo/redirect/", saml2.BINDING_HTTP_REDIRECT)
                ],
            },
            'name_id_format': [NAMEID_FORMAT_EMAILADDRESS, NAMEID_FORMAT_UNSPECIFIED],
            'sign_response': True,
            'sign_assertion': True,
            'want_authn_requests_signed': True,
        },

IDP has no field for Entity ID. The entity ID https://127.0.0.1:81 is being fetched from DB which belong to SP i.e. Mautic.

djangosmal2idp does not create any db tables for IDPs .

shivshankardayal avatar Jul 15 '22 09:07 shivshankardayal