ruby / ruby/net-imap

Should we create a shared net-sasl gem?

Open
#23 6 comments 1 reaction 2 assignees View on GitHub

@shugo is already working on this.

Since Apr 28, 2021.

SASL :lock:
Dominant language
Ruby
Stars
118
Forks
43
Avg merge
1d 23h
Merged PRs (30d)
26

Description

Currently, the following gems duplicate partial support for a small subset of SASL mechanisms:

  • net-imap
  • net-smtp
  • net-pop (it's actually missing, but it should be in there)
  • net-ldap
  • blather (XMPP)
  • memcached
  • dalli (another memcached client)
  • ...and probably many others.

This duplication and incomplete support basically defeats the purpose of SASL. It seems to me that SASL is used in a wide enough number of internet protocols that some level of SASL support should be in stdlib. See e.g. it's in java standard edition

We could start with a very simple API, which only handles client-side authentication and doesn't do much more than Net::IMAP already does. Simply providing a standard for pluggable support is useful. E.g here's a starter proposal:

  • class Net::SASL::Registry to allow non-global config, so e.g. a mechanism could be added to Net::IMAP without affecting other libraries.
    • #add_authenticator(name, mechanism_class)
    • #authenticator(name, *args)
    • both of these methods would also be available from a global registry on Net::SASL
  • Net::SASL::Authenticator interface (can provide a super-class with NotImplementedError on perform):
    • #initialize(*credentials, uri: nil)
      • some mechanisms require the host and port, and supporting that in the generic interface simplifies making clients work properly regardless of which mechanism is selected.
    • #supports_initial_response?
    • #process(challenge) - just as with Net::IMAP. IR sends a nil challenge
    • #done? - for mechanisms implementing a state machine, users of the library can know it is done without needing to call #perform and catch an exception.
    • respond_to?(...)could be used for backwards compatibility with Net::IMAP authenticators which haven't yet been updated to add supports_initial_response? or #done?.
  • utility methods:
    • Net::SASL.saslprep(string) - implements RFC4013, which is required by some mechanisms and recommended for others

And, of course, we could start by adding the existing Net::IMAP mechanisms. But it would be simple and very useful to add OAUTHBEARER and some others as well.

I've marked #22 as a draft, pending some discussion about this. Is this the correct place to discuss this? Should I create a ticket in the ruby issue tracker?

  • #22
  • #183
  • #187
  • #194
  • #195

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.