Repository navigation
Issue with SimpleSAMLphp 1.19.8 #366
Copy link
Copy link
Open
Labels
DocumentationIssues that document features and specific configuration/use casesIssues that document features and specific configuration/use casesquestion
Description
Hi,
I'm having some issues with correctly logging in with this test docker image https://github.com/kristophjunge/docker-test-saml-idp .
I can bring up the SimpleSAMLphp login page via django and it successfully logs in on SimpleSAMLphp server with test user data. However, when I'm trying to parse the response from SimpleSAMLphp, the response.assertion and response.assertions array are both blank, as well as response.ava. This causes the error below:
`saml2.response.StatusInvalidAuthnResponseStatement: The Authn Response Statement is not valid
ERROR 2023-03-23 16:56:56,871 log 14996 123145691701248 Internal Server Error: /saml2_auth/acs/
Traceback (most recent call last):
File "/Users/robertm/dev/platform/d3_platform/lib/python3.9/site-packages/asgiref/sync.py", line 486, in thread_handler
raise exc_info[1]
File "/Users/robertm/dev/platform/d3_platform/lib/python3.9/site-packages/django/core/handlers/exception.py", line 43, in inner
response = await get_response(request)
File "/Users/robertm/dev/platform/d3_platform/lib/python3.9/site-packages/django/core/handlers/base.py", line 253, in _get_response_async
response = await wrapped_callback(
File "/Users/robertm/dev/platform/d3_platform/lib/python3.9/site-packages/asgiref/sync.py", line 448, in __call__
ret = await asyncio.wait_for(future, timeout=None)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/tasks.py", line 442, in wait_for
return await fut
File "/Users/robertm/dev/platform/d3_platform/lib/python3.9/site-packages/asgiref/current_thread_executor.py", line 22, in run
result = self.fn(*self.args, **self.kwargs)
File "/Users/robertm/dev/platform/d3_platform/lib/python3.9/site-packages/asgiref/sync.py", line 490, in thread_handler
return func(*args, **kwargs)
File "/Users/robertm/dev/platform/d3_platform/lib/python3.9/site-packages/sentry_sdk/integrations/django/views.py", line 85, in sentry_wrapped_callback
return callback(request, *args, **kwargs)
File "/Users/robertm/dev/platform/d3_platform/lib/python3.9/site-packages/django/views/generic/base.py", line 103, in view
return self.dispatch(request, *args, **kwargs)
File "/Users/robertm/dev/platform/d3_platform/lib/python3.9/site-packages/django/utils/decorators.py", line 46, in _wrapper
return bound_method(*args, **kwargs)
File "/Users/robertm/dev/platform/d3_platform/lib/python3.9/site-packages/django/views/decorators/csrf.py", line 55, in wrapped_view
return view_func(*args, **kwargs)
File "/Users/robertm/dev/platform/d3_platform/lib/python3.9/site-packages/django/views/generic/base.py", line 142, in dispatch
return handler(request, *args, **kwargs)
File "/Users/robertm/dev/platform/d3_platform/src/platform_v2/accounts/views.py", line 281, in post
session_info = response.session_info()
File "/Users/robertm/dev/platform/d3_platform/lib/python3.9/site-packages/saml2/response.py", line 1099, in session_info
raise StatusInvalidAuthnResponseStatement("The Authn Response Statement is not valid")`
I was hoping you could please advise as to what may be the issue. It is worth noting this exact same docker image works with django-saml2-auth (but an older version), I am migrating over to your well defined package.
Regards,
Rob
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
DocumentationIssues that document features and specific configuration/use casesIssues that document features and specific configuration/use casesquestion
Activity
peppelinux commentedon Mar 23, 2023
it seems that you have to map the user attributes and the format of these in
https://pysaml2.readthedocs.io/en/latest/howto/config.html#requested-attribute-name-format
and
https://github.com/IdentityPython/djangosaml2/blob/master/djangosaml2/tests/attribute-maps/saml_uri.py
rmincling commentedon Mar 23, 2023
So heres my config
PHP config
and in my settings.py
and
Am I missing something?
rmincling commentedon Mar 23, 2023
Forgot to mention I'm on Django==4.1.7
peppelinux commentedon Mar 23, 2023
look at this
https://pysaml2.readthedocs.io/en/latest/howto/config.html#requested-attribute-name-format
it depends on which format your IDP uses, if BASIC or URI
here an example of attribute mapping with uri
https://github.com/IdentityPython/djangosaml2/blob/master/djangosaml2/tests/attribute-maps/django_saml_uri.py
please check if you have to configure it with uri or basic, then create your attribute-map file and put in a path configured in attribute_map_dir
rmincling commentedon Mar 23, 2023
oh, so attribute_map_dir is mandatory? Apologies, this is new to me, I've inherited a Django setup that was using django-saml2-auth which didn't seem to need this defined.
rmincling commentedon Mar 24, 2023
So this is the IDP metadata output from the IDP
No format is stated, so does it default to URI?
peppelinux commentedon Mar 24, 2023
please share also an example response
rmincling commentedon Mar 24, 2023
Sure, here you go, it looks like its using basic formatting, I don't seem to be able to get the formatting of my attribute map file correct? The response.ava and assertion/assertion attributes are all empty, even though the raw SAML response has the authenticated user data in the AttributeStatement.
Its also worth noting that i receive this exact same response in my previous setup using django-saml2-auth, Django 2.22 and pysaml2 7.4.1, the SAML response object has ava, assertion and assertions attributes all populated. So its definitely something I'm missing when setting this all up using djangosaml2.
rmincling commentedon Mar 24, 2023
Just to add I've tried an attribute mapping file with various definitions (below) and still the same result
and
rmincling commentedon Mar 24, 2023
Could the issue I'm having, have anything to do with? https://djangosaml2.readthedocs.io/contents/miscellanea.html#simplesamlphp-issues
If so, I'm not clear on how to fix.
But as I said above, this exact same IDP test setup works with django-saml2-auth with Django 2.22 and an older version of pysaml2 (6.5.0). Whereas now I'm using djangosaml2 with django 4.1.7 and pysaml2==7.4.1.
rmincling commentedon Mar 24, 2023
Well I may as well add the solution to this. In the ['service']['sp']['endpoints'] section of my SAML_CONFIG I had this:
Not realising that I missed out defining an 'assertion_consumer_service' entry for the BINDING_HTTP_POST binding, so i changed it to this...
This resulted in the SAML response object to detect and populate the response.ava, assertion and assertions attributes.
It's also worth noting that I did not require an attribute mapping directory/file.
peppelinux commentedon Mar 24, 2023
Thank you @rmincling for have shared this!
Please feel free to add this issue in a trouble shooting section in the documentation, with a Pull Request, or any other contributions to help user in using this project
best!