You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
RFC 5849 §3.4.1.3.1 mandates that if the HTTP request contains a single valid application/x-www-form-urlencoded entity-body, its contents be parsed into key/value pairs and added to the list of parameter sources that are covered by the OAuth 1 signature.
Currently, passport-http-oauth checks whether the Content-Type is application/x-www-form-urlencoded and uses req.body if it is. This requires a separate middleware to be present in the chain to decode the entity-body to req.body. Furthermore, this requires said middleware to decode it to a simple list of key/value pairs to follow the spec. Unfortunately, the common body-parser middleware urlencoded() does not do this.
Consider:
POST /test HTTP/1.0
Content-Type: application/x-www-form-urlencoded
Content-Length: 15
foo=bar&foo=baz
As documented in the Node.js docs, querystring.parse, which is called if {extended: false}, parses this request body as:
req.body={'foo': ['bar','baz']}
As a result, passport-http-oauth attempts to sign the string ...%26foo%3Dbar%252Cbaz instead of the expected ...%26foo%3Dbar%26foo%3Dbaz, and authentication fails when it should succeed (and succeeds when it should fail, if the client does the same!).
qs.parse, which is called if {extended: true}, doesn’t explicitly document this in the README, but as far as I can tell from the source code, it does the same and this cannot be disabled. Furthermore, it also parses several special syntaxes for complex objects and arrays.
The text was updated successfully, but these errors were encountered:
RFC 5849 §3.4.1.3.1 mandates that if the HTTP request contains a single valid
application/x-www-form-urlencoded
entity-body, its contents be parsed into key/value pairs and added to the list of parameter sources that are covered by the OAuth 1 signature.Currently,
passport-http-oauth
checks whether the Content-Type isapplication/x-www-form-urlencoded
and usesreq.body
if it is. This requires a separate middleware to be present in the chain to decode the entity-body toreq.body
. Furthermore, this requires said middleware to decode it to a simple list of key/value pairs to follow the spec. Unfortunately, the commonbody-parser
middlewareurlencoded()
does not do this.Consider:
As documented in the Node.js docs,
querystring.parse
, which is called if{extended: false}
, parses this request body as:As a result,
passport-http-oauth
attempts to sign the string...%26foo%3Dbar%252Cbaz
instead of the expected...%26foo%3Dbar%26foo%3Dbaz
, and authentication fails when it should succeed (and succeeds when it should fail, if the client does the same!).qs.parse
, which is called if{extended: true}
, doesn’t explicitly document this in the README, but as far as I can tell from the source code, it does the same and this cannot be disabled. Furthermore, it also parses several special syntaxes for complex objects and arrays.The text was updated successfully, but these errors were encountered: