rohe/pysaml2 — pull request #144 by patrickbr (2014-09-29 16:04:17+00:00)
Title: Fix for POST requests failing with 500

There seems to be a problem with the _get_post() method in the SAML2Plugin for repoze.who. When used with pyramid and repoze.who, all POST requests fail with code 500 as soon as pysaml2 is set as a repoze.who identifier plugin. This is because at the time pyramid is reading the environ dict, CONTENT_LENGTH is set to the size of the POST request, but environ[wsgi.input] is empty. My guess is that the restoring of environ['wsgi.input'] via

environ['wsgi.input'] = StringIO(body)

is ineffective because environ['wsgi.input'] is emptied/read again afterwards by cgi.FieldStorage().

I rewrote _get_post() with a simplier method using using parse_qs to get a dict of the POST parameters and removed the now unneeded cgi_field_storage method. environ['wsgi.input'] is restored immediately after reading it and is never touched again.