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
I was stuck on this for a while, but finally got it working.
I was able to get RestClient to work fine with ruby-ntlm by making a RestClient.get to one of the protected wiki pages, with a call to ntlm_auth in a before_execution_proc. However, when I tried to use it with MWG, it was getting stuck with an argument error. traced to this routine in Net::HTTPGenericRequest
# File lib/net/http.rb, line 1630defset_body_internal(str)#:nodoc: internal use onlyraiseArgumentError,"both of body argument and HTTPRequest#body set"ifstrand(@bodyor@body_stream)self.body=strifstrend
A short debugging session later, it was clearly in this code that the error lies. I changed the code above and the way credentials are handled with some duck punching, and got the following:
require'rubygems'require'ntlm/http'require'media_wiki'require'pp'# Some serious duck punching here to see if it will work this waymoduleRestClientclassRequestdefsetup_credentials(req)req.ntlm_auth('me','example.com','password')endendendmoduleNetclassHTTPGenericRequestdefset_body_internal(str)#:nodoc: internal use onlyraiseArgumentError,"both of body argument and HTTPRequest#body set"if(strand@bodyandstr != @body)or(strand@body_stream)self.body=strifstrendendendmw=MediaWiki::Gateway.new('https://example.com/wiki/api.php')ppmw.get('api_test/test_page')
Using this code, things work. The only real hack is to let the set_body_internal method succeed if the str value is the same as the current @Body (but not for streams) -- asking to change something to what it already is doesn't seem like an error so much to me. Still, this is the Net module here, so I don't want to muck with it unless its inescapable.
It seems that there must be something in MWG that is exercising this error. The stack trace points to:
ArgumentError: both of body argument and HTTPRequest#body set
from /Users/raels/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/net/http.rb:1523:in `set_body_internal'
from /Users/raels/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/net/http.rb:1046:in `__request__'
from /Users/raels/.rvm/gems/ruby-1.8.7-p334/gems/rest-client-1.6.7/lib/restclient/net_http_ext.rb:51:in `request_without_ntlm_auth'
from /Users/raels/.rvm/gems/ruby-1.8.7-p334/gems/ruby-ntlm-0.0.1/lib/ntlm/http.rb:42:in `request'
from /Users/raels/.rvm/gems/ruby-1.8.7-p334/gems/rest-client-1.6.7/lib/restclient/request.rb:176:in `transmit'
from /Users/raels/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/net/http.rb:543:in `start'
from /Users/raels/.rvm/gems/ruby-1.8.7-p334/gems/rest-client-1.6.7/lib/restclient/request.rb:172:in `transmit'
from /Users/raels/.rvm/gems/ruby-1.8.7-p334/gems/rest-client-1.6.7/lib/restclient/request.rb:64:in `execute'
from /Users/raels/.rvm/gems/ruby-1.8.7-p334/gems/rest-client-1.6.7/lib/restclient/request.rb:33:in `execute'
from /Users/raels/.rvm/gems/ruby-1.8.7-p334/gems/rest-client-1.6.7/lib/restclient.rb:72:in `post'
from /Users/raels/.rvm/gems/ruby-1.8.7-p334/gems/mediawiki-gateway-0.4.3/lib/media_wiki/gateway.rb:573:in `make_api_request'
from /Users/raels/.rvm/gems/ruby-1.8.7-p334/gems/mediawiki-gateway-0.4.3/lib/media_wiki/gateway.rb:64:in `get'
I am guessing that this is some strange interaction between all three gems and the "request" methods in each.
So, before I go any deeper, is there an approved way to do NTLM auth in MGW? If not, any ideas about what might be the interaction here?
Any help appreciated.
The text was updated successfully, but these errors were encountered:
I was stuck on this for a while, but finally got it working.
I was able to get RestClient to work fine with ruby-ntlm by making a RestClient.get to one of the protected wiki pages, with a call to ntlm_auth in a before_execution_proc. However, when I tried to use it with MWG, it was getting stuck with an argument error. traced to this routine in Net::HTTPGenericRequest
A short debugging session later, it was clearly in this code that the error lies. I changed the code above and the way credentials are handled with some duck punching, and got the following:
Using this code, things work. The only real hack is to let the set_body_internal method succeed if the str value is the same as the current @Body (but not for streams) -- asking to change something to what it already is doesn't seem like an error so much to me. Still, this is the Net module here, so I don't want to muck with it unless its inescapable.
It seems that there must be something in MWG that is exercising this error. The stack trace points to:
I am guessing that this is some strange interaction between all three gems and the "request" methods in each.
So, before I go any deeper, is there an approved way to do NTLM auth in MGW? If not, any ideas about what might be the interaction here?
Any help appreciated.
The text was updated successfully, but these errors were encountered: