Use of webob.Reponse in AuthProtocol middleware break content-type handling

Bug #1466499 reported by Chris Dent
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
keystonemiddleware
Fix Released
High
Jamie Lennox

Bug Description

Commit 675729be2e3073204e6acc1627394f53f3e3cf51[1] introduces webob into the middeware handling: the enclosed app is called with `request.get_response(self._app).

If the self._app returns a response with no content-type then webob will apply a default header[2]. For responses that have bodies this is okay, but for responses that do not, such as 204 or 304 this is invalid and breaks tests that lint WSGI responses[3].

Earlier versions of keystonemiddleware didn't use webob so this problem didn't raise its head.

One might argue that the bug here is in webob (I'll report one there too) but in the meantime a solution might be to create a subclass of Response (or otherwise invade Reponse) that does not have a default_content_type.

[1] https://github.com/openstack/keystonemiddleware/blob/675729be2e3073204e6acc1627394f53f3e3cf51/keystonemiddleware/auth_token/__init__.py#L606

[2] https://github.com/Pylons/webob/blob/58654bb0e43ad56c322b290422eef7a281c9c64a/webob/response.py#L113

[3] https://review.openstack.org/#/c/193036/

Revision history for this message
David Stanek (dstanek) wrote :

We should definitely fix this in ksm, but I would agree the behavior in WebOb is questionable. We have to deal with similar behaviors in Keystone already: http://git.openstack.org/cgit/openstack/keystone/tree/keystone/common/wsgi.py#n770

I wouldn't be surprised if they mark the bug as "won't fix" because it would break their consumers who may be expecting that behavior.

Changed in keystonemiddleware:
status: New → Confirmed
importance: Undecided → High
Revision history for this message
Chris Dent (cdent) wrote :
Revision history for this message
Dolph Mathews (dolph) wrote :

I believe keystone itself used to have this issue as well. If you can cause an error that keystone can't catch itself, then I think you should still be able to reproduce this against keystone.

Changed in keystonemiddleware:
assignee: nobody → Jamie Lennox (jamielennox)
status: Confirmed → In Progress
Changed in keystonemiddleware:
status: In Progress → Fix Committed
Changed in keystonemiddleware:
milestone: none → 2.1.0
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.