Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Faraday #998

Merged
merged 41 commits into from
Jul 10, 2024
Merged

Faraday #998

merged 41 commits into from
Jul 10, 2024

Conversation

LukeIGS
Copy link
Contributor

@LukeIGS LukeIGS commented Jan 4, 2024

What kind of change is this?
Conversion to faraday full of breaking changes

Did you add tests for your changes?

Yes

Summary of changes

#992

So far the biggest changes of note are that faraday doesn't support setting cert files except the ca, it doesn't support using an alternative ssl cipher and since it doesn't open cert files, it doesn't worry about using a password to decrypt them. The end user is expected to open and decrypt the client key using openssl and provide the result to faraday instead. As such I went ahead and deprecated those globals for now. If we wanted to keep this functionality, savon would have to handle those logic flows.

Faraday also uses various middlewares to enhance its auth capabilities. Currently I'm solving for NTLM in savon proper, but it might make more sense to write a middleware to handle NTLM auth, along the lines of how digest is handled.

Since these middlewares are not included out of box with faraday, I've added them as development dependencies and added errors when trying to load them if they aren't present. I used the same approach for NTLM auth, though rubyntlm is such a light weight gem, adding it as a solid dep would probably be acceptable too.

Worth noting that CI will not be able to build this unless the associated wasabi version is built and available, since it also relies on some very minor changes to support faraday.
see: savonrb/wasabi#116

The API for adapters is also slightly different since savon's adapters are often built using parameters, so I just take an array of options to forward

@pcai
Copy link
Member

pcai commented Jan 5, 2024

Thanks for putting this together. planning to take a look at it all this weekend

@pcai
Copy link
Member

pcai commented Jan 8, 2024

Thanks again for this PR. Here's a quick plan:

  • get Update to be compatible with Faraday wasabi#116 merged in and cut a release of wasabi
  • rebase this branch and retest, get everything green and document an upgrade path
  • cut a prerelease and try to get some feedback from the wild
  • do a final release for savon 3.0 after a few weeks

thoughts? let me know if I can help with any part in particular

@LukeIGS
Copy link
Contributor Author

LukeIGS commented Jan 8, 2024

The biggest concern i have is whether NTLM is going to function correctly, i have a local server i can use to integration test it though so pre-release sounds like the best course of action.

Upgrade path is going to be interesting, for the most part the biggest thing is going to be for anyone who actually uses the encrypted cert file functionality, they'll need to open the cert file using openssl and provide it that way.
https://docs.ruby-lang.org/en/3.2/OpenSSL.html#module-OpenSSL-label-Loading+an+Encrypted+Key

We could provide a helper internally that does this in order to preserve that API though.

I guess also people using custom adapters would need to rebuild their adapter on top of faraday's API.

I tried to preserve as much public api as i could.

@LukeIGS
Copy link
Contributor Author

LukeIGS commented Jan 9, 2024

looks like code climate is happy now.

@LukeIGS
Copy link
Contributor Author

LukeIGS commented Jan 9, 2024

@pcai do have a quick question for you, regarding the implementation of cookie parsing. Currently I have it set up so you can pass array'd cookie values under _: in the cookie hash, though i feel that's a little unclear, ex:
https://github.com/savonrb/savon/pull/998/files#diff-04f40daa7e1b300e4e12f372a2632611ea7434aa135c935917652720a1fc3e7eR231-R235

Implemented at
https://github.com/savonrb/savon/pull/998/files#diff-92754a50069d8bad42f3a8abb8d0be2cf0606271ebf4077ab1430787abb98263L102-L104

Can you think of a better way to handle this?

@LukeIGS
Copy link
Contributor Author

LukeIGS commented Mar 18, 2024

I suppose we could just assign to nil

{
  'some-cookie': 'choc-chip'
  'HttpOnly': nil
}

@eclectic-coding
Copy link

Checking in on the status of this PR.

I maintain a Rails application that uses savon and with the latest Ruby (3.3.3), I am getting a lot of Rack::Utils::HeaderHash errors. Our application works fine with Ruby 3.3.1.

I think this PR might resolve our issues and allow us to upgrade.

Just curious.

@LukeIGS
Copy link
Contributor Author

LukeIGS commented Jul 8, 2024

Honestly forgotten about, i need to fix the cookie approach, I'll look into getting that done asap, thanks for the reminder. (Timeframe is probably within the next 3 or so days.)

@LukeIGS
Copy link
Contributor Author

LukeIGS commented Jul 8, 2024

@pcai Looks like the test application relies on Rack::Auth::Digest::MD5 which is gone, so i'll have to update that too.

Seems like rack's opinion on the subject is that the upgrade path for digest auth is that there is no upgrade path for digest auth, and any tooling using it should simply drop support. I'm going to go that route for now...

@LukeIGS
Copy link
Contributor Author

LukeIGS commented Jul 8, 2024

looks like 3.4 removes httpclient from stdlib... guess i'll add that to our gemspec as a dev gem.

@LukeIGS
Copy link
Contributor Author

LukeIGS commented Jul 8, 2024

@pcai Alright, at this point we're probably ready to cut a prerelease. The deprecation specs just fail on 3.4 because of ascii encoding differences, and fixing that spec on 3.4 would break it on every other version.

@pcai
Copy link
Member

pcai commented Jul 8, 2024

thx @LukeIGS i will take a look today

@eclectic-coding please make sure you force rack < 3.1 - the recent release of rack, if bundled, forces an old and incompatible version of httpi 3.x to be resolved, which is the cause of your errors. This was fixed in httpi 4.0.3 https://github.com/savonrb/httpi/releases/tag/v4.0.3

I plan on making a minor bugfix release this wk to mainline to force httpi 4.x+

Copy link
Member

@pcai pcai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for the work on this. I have inline thoughts on DeprecatedOptionError - but here are some more general ones:

  • It's not immediately clear to me why all the metaprogramming is really needed
  • Most of it is to support an option attribute but I don't really see the value of it, since its just a variable used in an error string builder. Why not just build the error string directly? Sure its easier to test, but the code doesn't need so much testing that it should be architected to prioritize it

spec/savon/http_error_spec.rb Outdated Show resolved Hide resolved
@locals[:soap_action] ||= soap_action
@globals[:endpoint] ||= endpoint
def handle_ntlm(connection)
ntlm_message = Net::NTLM::Message
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do this?

spec/savon/options_spec.rb Outdated Show resolved Hide resolved
lib/savon/options.rb Outdated Show resolved Hide resolved
@pcai
Copy link
Member

pcai commented Jul 8, 2024

Unless I'm reading the logs wrong, its more than just an encoding difference - ruby-head returns the full namespace in addition to the method name

image

@eclectic-coding
Copy link

@pcai Thanks. I will give this a try for now.

Thank you @LukeIGS and @pcai for your work and commitment

@LukeIGS LukeIGS requested a review from pcai July 9, 2024 12:42
Copy link
Member

@pcai pcai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for taking this on.

@pcai pcai merged commit 725855d into savonrb:main Jul 10, 2024
7 checks passed
@LukeIGS LukeIGS deleted the faraday branch July 11, 2024 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants