Disable basic_auth for Savon WSDL call - ruby

Is it possible to disable authentication (basic_auth) when Savon attempts to retrieve the WSDL?
It appears that this changed somewhere around 2.0 or 2.1 and now the authentication headers are always being sent, which the server I am calling throws an error when this happens.

Savon will perform basic auth only if you provide :basic_auth while creating the Savon.client object.

Related

Apache NiFi NTLM Authentication 401

I'm having troubles authenticating NiFi to a SOAP WebService, using a NTLM Authentication.
I've using this custom processor:
https://github.com/peetkes/nifi-http-processor
I've created a simple flow, with a FlowFile that contains the XML request, passed to the CustomInvokeHTTP Processor.
The problem is that I obtain "Error 401 Unauthorized".
I tried to use the same credentials with SOAPUI and they work.
I attach the flow and the processor properties.
Is there something else I can try?
I don't really know what to do.
Thank you so much!

google-api-ruby-client 0.9 tokeninfo lacks an example

I thought that using Google's official ruby client API would be the easiest way to validate an access_token that hits my backend server.
Not really.
Version 0.9 has not a simple sample of validating an access token and API docs doesn't help neither.
I have got this far:
require 'google/apis/oauth2_v2'
oauth = Google::Apis::Oauth2V2::Oauth2Service.new
oauth.tokeninfo({access_token: 'aaaaaaaa...'})
=> Google::Apis::ClientError: Invalid request
docs on google-api-client-0.9.4/generated/google/apis/oauth2_v2/service.rb say that tokeninfo method raises:
[Google::Apis::ServerError] An error occurred on the server and the request can be retried
[Google::Apis::ClientError] The request is invalid and should not be retried without modification
[Google::Apis::AuthorizationError] Authorization is required
How can I tell that the token is invalid ?!?
Can you guys share some examples ?

EWS Basic/NTLM Authentication

I'm currently trying to send a SOAP request to an Exchange server, but I'm getting a 401 Unauthorized. I repeated the request using Postman, and it looks like it's trying to do NTLM authentication. However, I want to authenticate using Basic authentication by using just a username/password. Is there any way to specify this in the message headers or something? Is this something that's configured on the server end?
If it's not possible, how do I go about implementing NTLM authentication? I'm very new to this, so any help/direction will be much appreciated.
Thanks!

Basic authentication in Github api with http request in Ruby?

I'm trying to use basic authentication in Github api. I wrote something like this:
require 'httpclient'
request = HTTPClient.new
request.set_basic_auth("http://api.github.com/authorizations", "my_username", "my_password")
request.get "http://api.github.com/user/repos"
and expect it returns the repos of a user. However, it keeps throwing an error:
Connection refused - connect(2) for "api.github.com" port 80 (Errno::ECONNREFUSED)
I know there are a whole bunch of gems like github, octokit that do the stuff for users. I want to try it myself. Does anyone know how do I authenticate with a simple http request in Ruby?
You need to make an HTTPS request instead of HTTP. Authentication always needs to use SSL.
You are also using the wrong URL's. As per their docs (https://developer.github.com/v3/auth/#basic-authentication) you need to set your basic authentication to the following path:
https://api.github.com/user
And make your repo request at:
"https://api.github.com/users/<USERNAME>/repos"
So your request would look something like
request = HTTPClient.new
request.set_basic_auth("https://api.github.com/user", "my_username", "my_password")
request.get "https://api.github.com/users/<USERNAME>/repos"
I suggest taking a look at the documentation that I linked to above, and make your first attempt by using curl requests, as they offer more information to help you debug.

Successfully calling a WCF Service from Ruby? Anyone?

I'm trying to integrate a rails application with a WCF service. I've tried soap4r and Savon with no love at all. As far as I can tell, none of the Ruby libraries support the newest version of SOAP.
The error that I was getting was:
Cannot process the message because the
content type 'text/xml;charset=UTF-8'
was not the expected type
'application/soap+xml; charset=utf-8'.'application/soap+xml; charset=utf-8'.
I managed to beat this error by changing the WCF service binding from wsHttpBinding to basicHttpBinding, but then received the new error:
The message with Action '' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None). (SOAP::FaultError)
Now, this error leaves me baffled because I don't see any way to configure endpoints in any of the Ruby libraries. Does anyone know?
Has anyone successfully called WCF services from Ruby?'application/soap+xml; charset=utf-8'.
Please note that I got this working...after I changed the web.config for the service to basicHttpBinding, Savon is able to send and receive messages. It is only soap4r that is unable to still and throws the Action '' error.
this may not be what you want t hear but I've recently been interacting with SOAP in Ruby.... It's not fun at all, none of the gems available are complete, stable or well documented and all seem to fall down when you add a tiny bit of complexity (passing an object containing some values instead of just passing a integer or string).
I ended up sniffing the request made by a .net client, then building objects that have a .to_xml method, taking a XML Builder object and adding it's own stuff..
That takes care of the request and then each service request method is custom made to extract the information needed for the result.
Very manual way to do it, and have to add more for every method i need to use but at least it works!
Some other guys I work with had success using JRuby and Axis. I stayed away from this as I wanted a pure Ruby solution.
Sorry I couldn't be of more help.. if you'd like I'll post my code to build the soap request...
I was running into the same issue with Savon with my WCF web service. The content error is because your service is expecting SOAP 1.2, but by default Savon sends the request as SOAP 1.1.
The Content-Type value for 1.1 is 'text/xml;charset=UTF-8', but if the server is configured for 1.2 (which is what wsHttpBinding is), the Content-Type must be 'application/soap+xml; charset=utf-8'.
I found this method on the Savon website:
response = client.request :get_user do
soap.version = 2
end

Resources