我正在尝试使用OneLoginSAML2模块实现SAML2 SSO功能。自述文件和演示中有很多信息。
我已经实现了其中的大部分,并且正在使用Samling工具测试我的ACS
端点。
我能够收到SAML响应,但在实现过程中出现上述错误。
我收到的XML看起来不错,第一个符号是<
。我不明白,问题出在哪里。请帮忙。
以下是完整的回溯:
Internal Server Error: /auth/sso/saml2/
Traceback (most recent call last):
File "/usr/local/lib/python3.4/site-packages/django/core/handlers/base.py", line 140, in get_response
response = middleware_method(request, callback, callback_args, callback_kwargs)
File "/usr/local/lib/python3.4/site-packages/debug_toolbar/middleware.py", line 78, in process_view
response = panel.process_view(request, view_func, view_args, view_kwargs)
File "/usr/local/lib/python3.4/site-packages/debug_toolbar/panels/profiling.py", line 151, in process_view
return self.profiler.runcall(view_func, *args, **view_kwargs)
File "/usr/local/lib/python3.4/cProfile.py", line 109, in runcall
return func(*args, **kw)
File "/code/authtoken/views.py", line 63, in sso_handler
resp = do_saml2(request)
File "/code/authtoken/sso/saml2/saml2.py", line 83, in do_saml2
auth.process_response()
File "/usr/local/lib/python3.4/site-packages/onelogin/saml2/auth.py", line 99, in process_response
response = OneLogin_Saml2_Response(self.__settings, self.__request_data['post_data']['SAMLResponse'])
File "/usr/local/lib/python3.4/site-packages/onelogin/saml2/response.py", line 39, in __init__
self.document = OneLogin_Saml2_XML.to_etree(self.response)
File "/usr/local/lib/python3.4/site-packages/onelogin/saml2/xml_utils.py", line 66, in to_etree
return OneLogin_Saml2_XML._parse_etree(xml)
File "/usr/local/lib/python3.4/site-packages/defusedxml/lxml.py", line 143, in fromstring
rootelement = _etree.fromstring(text, parser, base_url=base_url)
File "src/lxml/lxml.etree.pyx", line 3228, in lxml.etree.fromstring (src/lxml/lxml.etree.c:79609)
File "src/lxml/parser.pxi", line 1848, in lxml.etree._parseMemoryDocument (src/lxml/lxml.etree.c:119128)
File "src/lxml/parser.pxi", line 1736, in lxml.etree._parseDoc (src/lxml/lxml.etree.c:117808)
File "src/lxml/parser.pxi", line 1102, in lxml.etree._BaseParser._parseDoc (src/lxml/lxml.etree.c:112052)
File "src/lxml/parser.pxi", line 595, in lxml.etree._ParserContext._handleParseResultDoc (src/lxml/lxml.etree.c:105896)
File "src/lxml/parser.pxi", line 706, in lxml.etree._handleParseResult (src/lxml/lxml.etree.c:107604)
File "src/lxml/parser.pxi", line 635, in lxml.etree._raiseParseError (src/lxml/lxml.etree.c:106458)
File "<string>", line 1
lxml.etree.XMLSyntaxError: Start tag expected, '<' not found, line 1, column 1
[2017/07/10 14:07:58] HTTP POST /auth/sso/saml2/ 500 [0.28, 172.17.0.1:53032]
我找到了。必须对响应 xml 进行base64
编码。然后正确处理它。