derivative network plugins

Created on 10 May 2023, about 1 year ago
Updated 16 May 2023, about 1 year ago

Problem/Motivation

Im currently developing a nextcloud social_auth module ( https://www.drupal.org/project/social_auth_nextcloud β†’ ). The draft is working well, but it has a limitation (correct me if I am wrong), nextcloud is self-hosted so it needs an base_url defined for each instance, so on to allow various nextclouds to provide oauth service is not possible. It will be great to offer various nextclouds to be defined as oauth server. Now the only way to get it is that I'll have to create a new network plugin for each one, duplicating the same code but changing the namespace, ids...

Is planned to add derivates of network plugins as in https://www.drupal.org/docs/drupal-apis/plugin-api/plugin-derivatives β†’ ? I think this could be useful to allow various keycloaks, drupals, gitlabs, mastodons... and any oauth provider that is not living in an enclosed domain.

✨ Feature request
Status

Fixed

Version

4.0

Component

Use-cases/requirements

Created by

πŸ‡ͺπŸ‡ΈSpain aleix

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @aleix
  • πŸ‡ΊπŸ‡ΈUnited States wells Seattle, WA

    Interesting. This definitely sounds like a use case worth supporting but I'm not familiar with derivatives. I'll do some ready but would also be happy to take advice and/or a PR here if you have any thoughts on how a specific approach might look.

  • πŸ‡ͺπŸ‡ΈSpain aleix

    Hi again wells, I have good news. After testing in my social_auth_nextcloud β†’ module just one thing is left to be done by now in social_auth module. Apart from this, all code must live in integration code. The only change is to prevent colons in config id in SocialAuthSettingsForm. I explain it below.

    The code change to be done in integrations that wants to gain derivative capabilities can be seen in this commit . It is a simple implementation of how a the derivative plugin could be done.

    Doing as this it will derivate Network plugin and Tasks so their resulting derivate plugins come from the value of simple "social_auth_nextcloud_instances" array defined in main settings.php, such as:

    $settings['social_auth_nextcloud_instances'] = [
      "nextcloud.example.org",
      "nuvo.example.org",
    ];

    I did it using this simple array in settings.php to illustrate how this must be done without oversizing the code, but i am planning an auxiliary config entity along with their forms to let user set the allowed social auth nextcloud instances from UI.

    One of the critical things to be aware of is that config id must be rewritten because id's cannot use colons, and as config id is obtained from pluginId and derivative plugins adds ":" in plugin ids, their ids must be replaced in settings form (i did a replace from ":" to "."). As the integration must extend the SocialAuthSettingsForm form to add the "url" field, the config id to be get or to be set could be overridden there, but as parent submit is also called in when extending social auth settings form, it needs to be replaced in SocialAuthSettingsForm also (hence the patch that I had attach in social_auth #3360455 issue ✨ Derivative network plugins Fixed ).

    I'll create some automated tests in social_auth_nextcloud β†’ , but it is working well in my manual tests.

  • Status changed to Needs review about 1 year ago
  • πŸ‡ͺπŸ‡ΈSpain aleix

    Finally https://www.drupal.org/project/social_auth_nextcloud β†’ is released right now, still depending on social_auth patch in https://www.drupal.org/project/social_auth/issues/3360455 ✨ Derivative network plugins Fixed to make it work. but anyway this is working fine, and passing functional tests (for block and settings).

    If anyone interested, here are the basic changes to be done if multiple derivatives of an integration is wanted: https://git.drupalcode.org/project/social_auth_nextcloud/-/compare/ec128...

    Could this be added to integrations in the list of social_auth 4.x implementers ?

    Obviously review of the module is really appreciated.

  • Status changed to Fixed about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States wells Seattle, WA

    Congrats! I have added Social Auth Nextcloud to list of 4.0.x implementors over on the Social Auth project page.

    I'm gonna close this issue and we'll track the ongoing work in ✨ Derivative network plugins Fixed .

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024