roundcube / roundcubemail

The Roundcube Webmail suite
https://roundcube.net
GNU General Public License v3.0
5.57k stars 1.6k forks source link

Provide imap auth interface for plugins #9418

Open jaudriga opened 1 month ago

jaudriga commented 1 month ago

Addresses #9377 .

Main change: Allows to use the rcmail::login() function for merely logging into IMAP by introducing a new flag $just_connect. This allows applications using the Roundcube Framework to reuse IMAP authentication logic.

Background: It would be beneficial for applications like Roundcube JMAP (see https://github.com/audriga/roundcube-jmap/pull/6 ) or Kolab's FreeBusy to reuse large parts of the existing IMAP Authentcation logic of Roundcube. This is my try at providing an interface for reusing that.

Minor additional change: Adds a function in rcube to connect to IMAP. I actually consider this optional as its only beneficial for FreeBusy for now. This would basically allow FreeBusy to just call rcube::imap_connect() instead of what they are doing right now (from lib/Kolab/FreeBusy/SourceIMAP.php):

// enable proxy authentication
if (!empty($config['proxy_auth'])) {
    $imap->set_options(array('auth_cid' => $config['proxy_auth'], 'auth_pw' => $config['pass']));
}

// authenticate user in IMAP
if (!$imap->connect($host, $config['user'], $config['pass'], $port, $ssl)) {
    Logger::get('imap')->addWarning("Failed to connect to IMAP server: " . $imap->get_error_code(), $config);
    return false;
}
pabzm commented 1 week ago

@jaudriga After reading the corresponding ticket I'm wondering you want this actually merged or if it's more of a proof of concept to illustrate your broader request?

jaudriga commented 6 days ago

@pabzm

It would be great to have this merged as this is an obvious and straight forward aspect of #9377 to address for me.

I realize that that might not address all aspects of #9377 , however, its an important and good step in the right direction.

Addressing even broader changes would be great, but not strictly necessary in my opinion. I would need a bit more support for those as a bunch of design decisions would need to be taken that I am not comfortable taking on my own.

I would suggest that we focus on this PR for now and potentially discuss about further improvements in #9377 .

jaudriga commented 5 days ago

I rebased on newest master as on of the CI jobs failed: https://github.com/roundcube/roundcubemail/actions/runs/9059543070/job/24905660338

pabzm commented 5 days ago

The CI will be fixed with #9449, please rebase again after that was merged.

jaudriga commented 2 days ago

I rebased again ;)

pabzm commented 2 days ago

@alecpl Any thoughts on this?