Forward-compatible SASL API
It is my belief that the current API for #start and #authenticate can't fully support every SASL mechanism. Most of the necessary changes have been implemented by #71, and are described in that ticket.
This PR adds a new Net::SMTP#auth method which is similar to #authenticate, but uses a different call signature: type is passed in either as a keyword argument or as the first positional argument. All other arguments are forwarded to the authenticator.
Although #71 updates #authenticate to forward keyword args and a block and makes username and secret both optional, there are limitations to maintaining backward-compatibility with the existing #authenticate method. Because the mechanism is last and optional it's not possible to use an authenticator with a single positional parameter or with more than two positional parameters. The call signature used by #auth avoids this problem.
As currently written, this PR depends on the following other PRs:
- #63
- #64
- #71
- ~#65~
- #72
- #66
- #73
- #67
This PR is intended as a transition between the v0.4.0 #authenticate method and a shared SASL implementation, either using net-imap's implementation or extracting it to a net-sasl gem (see ruby/net-imap#23). The #auth and #start API in this PR are both compatible with all of the SASL mechanisms supported by net-imap v0.4.1. The following PRs depend on this one:
- #69
- #70
I've been using a personal fork of net-smtp that shares the SASL implementation with net-imap, for over a year. It was always my intention to create a PR, but... I never made time for it. My apologies: this PR is probably larger than it would have been if I'd submitted a year ago!
This PR is still fairly large. So I've converted it to draft, and I'm going to split it into several more bite-sized PRs which can mostly be applied directly to master without any dependencies on other PRs.
I'd still welcome feedback on this PR as it is. Unless I hear feedback otherwise, I don't expect the final form will be significantly different from this.