pelle / oauth-plugin

Rails plugin for OAuth
http://stakeventures.com/articles/2009/07/21/consuming-oauth-intelligently-in-rails
MIT License
717 stars 217 forks source link

Set content type "application/x-www-form-urlencoded" when returning tokens to client #161

Open mattbsea opened 3 years ago

mattbsea commented 3 years ago

https://tools.ietf.org/html/rfc5849#page-9

RFC 5849 requires or at least strongly suggests that tokens be returned with content type "application/x-www-form-urlencoded"

From Section 2.1: "The server MUST verify (Section 3.2) the request and if valid, respond back to the client with a set of temporary credentials (in the form of an identifier and shared-secret). The temporary credentials are included in the HTTP response body using the "application/x-www-form-urlencoded" content type as defined by [W3C.REC-html40-19980424] with a 200 status code (OK)."

I believe the MUST applies to the 2nd sentence as well. The first sentence declares the server MUST respond with temporary credentials. The 2nd sentence goes on to clarify that the credentials "are included in the HTTP response body using the "application/x-www-form-urlencoded" content type"

Additionally, every example given in the RFC uses "application/x-www-form-urlencoded"

oauth-plugin currently returns content type "text/plain". This causes a problem in clients who enforce strict adherence to the RFC's content-type "application/x-www-form-urlencoded"

NB: I'm not a rails developer. I discovered this when working with the Qt Framework OAuth1 client. The code changes in this PR have not been tested.