net-pop icon indicating copy to clipboard operation
net-pop copied to clipboard

Add support for CAPA command

Open nevans opened this issue 2 years ago • 1 comments

This adds support for asking a POP server about its capabilities (RFC2449).

  • Adds Net::POP3Command#capa, which issues the CAPA command and encodes the result as a hash of {tag => params for tag, *params in each_list_item}. Tags and params are both upcased, to simplify case insensitive matching.
  • Adds Net::POP3#capabilities, which caches the result from command.capa.
  • Adds Net::POP3#capable?, which returns whether #capabilities includes a specific tag and param.
  • Adds Net::POP3#clear_cached_capabilities, which clears the capabilities cache.
  • Adds Net::POP3#sasl_capable? and Net::POP3#sasl_mechanisms, which query support of the "SASL" capabability.

Note that the STLS extension modifies the CAPA requirements. If support is added for STLS, the capabilities cache must be reset.


This is needed in order to properly support SASL authentication using the AUTH command (RFC5034).

And a basic SASL implementation should be the basis for supporting OAuth2 (whether via the non-standard XOAUTH2 SASL mechanism or the standard OAUTHBEARER SASL mechanism). Therefore, CAPA is a requirement for proper implementation of OAuth2.

nevans avatar Oct 18 '23 02:10 nevans

I rebased this and changed it a little. Now it only add the #capa method to POP3Command, and the other methods are implemented directly on POP3.

nevans avatar Jun 23 '24 18:06 nevans