OneLogin SAML2模块抛出错误`lxml.etree.XMLSyntaxError:期望开始标记,'<'未找到,第1行,第1列

时间:2017-07-10 14:28:18

标签: django lxml python-3.4 saml-2.0 onelogin

我正在尝试使用OneLogin SAML2 module来实现 SAML2 SSO 功能。自述文件和演示中有很多信息。

我已经实现了大部分功能,我正在使用Samling tool测试我的ACS端点。

我能够收到 SAML 回复,但我在实施中的this point收到了上述错误。

我收到的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]

1 个答案:

答案 0 :(得分:0)

我找到了。响应xml必须为base64编码。然后它被正确处理。