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

Provide interfaces for Plugins exposing an API #9377

Open
jaudriga opened this issue Mar 4, 2024 · 2 comments
Open

Provide interfaces for Plugins exposing an API #9377

jaudriga opened this issue Mar 4, 2024 · 2 comments

Comments

@jaudriga
Copy link

jaudriga commented Mar 4, 2024

audriga/roundcube-jmap is a plugin that exposes a JMAP API focusing on Contacts and Calendars within Roundcube. Currently, this involves duplicating some of Roundcube's index.php code, which is not ideal for maintenance and compatibility.

It would be helpful if Roundcube could provide some interfaces or hooks for plugins that want to expose an API. Presently, our implementation involves duplicating the following from RC's index.php:

  • Including environment via program/include/iniset.php .
  • Authentication by calling the authenticate hook and subsequently rcmail->login().

Including the iniset file might already be sufficient for such use cases. However, passing basic-auth credentials to the authenticate hook and the subsequent login is currently not ideal.

One requirement for us would be that this is also compatible with Roudcube installations in cPanel, which might pose additional requirements on authentication compared to vanilla Roundcube. At least, when we tested against RC in cPanel we ran into authentication issues when not using any hooks. Especially the authentication hook might be important.

Additional Information:

All code that audriga/roundcube-jmap duplicated from the index.php can be seen in bridge.php.

This issue is related to the discussions in #5918.

Another example of a plugin that provides an API is freebusy, which you can find here: https://git.kolab.org/source/freebusy/. My understanding is that it seem to differ from our approach by:

define('RCUBE_INSTALL_PATH', '../../');
define('RCUBE_CONFIG_DIR',   RCUBE_INSTALL_PATH . '/config/');
define('RCUBE_PLUGINS_DIR',  RCUBE_INSTALL_PATH . '/lib/plugins/');
...

@alecpl
Copy link
Member

alecpl commented Mar 10, 2024

There's the startup hook. I'm not sure what else would you need. Provide a pull request.

jaudriga added a commit to audriga/roundcubemail that referenced this issue Apr 16, 2024
Fixes roundcube#9377 . Allows rcmail::login() to be reused in plugins providing
an API. The login function provides some useful logic for connecting to
IMAP sources like checking credentials for validity or converting
usernames in some cases.

Before this change the login function always also created non-existing
users or set some sesison vars, which what API plugins would like to
avoid.
jaudriga added a commit to audriga/roundcubemail that referenced this issue Apr 17, 2024
Fixes roundcube#9377 . Allows rcmail::login() to be reused in plugins providing
an API. The login function provides some useful logic for connecting to
IMAP sources like checking credentials for validity or converting
usernames in some cases.

Before this change the login function always also created non-existing
users or set some sesison vars, which what API plugins would like to
avoid.
@jaudriga
Copy link
Author

I opened up a #9418 . I hope this makes it clearer what I meant initially. The JMAP RC Plugin is not a plugin in a strict sense, it follows a similar approach as Kolab's FreeBusy plugin, but uses the rcmail class to reuse authentication logic.

jaudriga added a commit to audriga/roundcubemail that referenced this issue Apr 17, 2024
Fixes roundcube#9377 . Allows rcmail::login() to be reused in plugins providing
an API. The login function provides some useful logic for connecting to
IMAP sources like checking credentials for validity or converting
usernames in some cases.

Before this change the login function always also created non-existing
users or set some sesison vars, which what API plugins would like to
avoid.
jaudriga added a commit to audriga/roundcubemail that referenced this issue May 14, 2024
Fixes roundcube#9377 . Allows rcmail::login() to be reused in plugins providing
an API. The login function provides some useful logic for connecting to
IMAP sources like checking credentials for validity or converting
usernames in some cases.

Before this change the login function always also created non-existing
users or set some sesison vars, which what API plugins would like to
avoid.
jaudriga added a commit to audriga/roundcubemail that referenced this issue May 16, 2024
Fixes roundcube#9377 . Allows rcmail::login() to be reused in plugins providing
an API. The login function provides some useful logic for connecting to
IMAP sources like checking credentials for validity or converting
usernames in some cases.

Before this change the login function always also created non-existing
users or set some sesison vars, which what API plugins would like to
avoid.
@alecpl alecpl added this to the later milestone Jun 9, 2024
jaudriga added a commit to audriga/roundcubemail that referenced this issue Jul 15, 2024
Fixes roundcube#9377 . Allows rcmail::login() to be reused in plugins providing
an API. The login function provides some useful logic for connecting to
IMAP sources like checking credentials for validity or converting
usernames in some cases.

Before this change the login function always also created non-existing
users or set some sesison vars, which what API plugins would like to
avoid.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants