shenyu icon indicating copy to clipboard operation
shenyu copied to clipboard

[Feature][Admin] Provisioning hook for out-of-tree plugins on client registration

Open Chrisp12138 opened this issue 2 weeks ago • 0 comments

Background

Shenyu supports loading custom plugins through the gateway ext-plugin mechanism (shenyu.extPlugin.*) and registering them in the admin plugin management. However, the admin-side provisioning such plugins need is only generated for built-in plugins:

  • plugin rows are seeded from PluginEnum;
  • namespace_plugin_rel rows make the plugin visible in the admin UI;
  • button permissions (plugin:<name>Selector:add|edit|delete|query, plugin:<name>Rule:*, plugin:<name>:modify) drive the admin UI action buttons;
  • ShenyuClientRegisterService implementations create selector/rule for built-in plugins when a business service registers, and are dispatched by rpcType only (shenyuClientRegisterService.get(meta.getRpcType())), where "http" is exclusively owned by ShenyuClientRegisterDivideServiceImpl.

As a result, every deployment of an out-of-tree plugin (e.g. a custom auth plugin loaded as an ext-plugin jar) currently requires manual SQL across six tables (plugin, namespace_plugin_rel, resource, permission, selector_condition/rule_condition, selector, rule), otherwise the plugin is invisible in the UI, renders no action buttons, and never executes in the gateway chain.

Expected behavior

An optional hook so out-of-tree plugins can participate in client-registration provisioning without patching shenyu source code, keeping built-in plugin behavior untouched.

Proposal

Add a small SPI invoked after the matching ShenyuClientRegisterService finishes processing a registration:

public interface ClientRegisterProvisioner {

    String pluginName();

    default boolean supports(final MetaDataRegisterDTO metaDataRegisterDTO) {
        return true;
    }

    void provision(final MetaDataRegisterDTO metaDataRegisterDTO);
}
  • Implementations are Spring beans and may ship inside the plugin jar placed on the admin classpath (same distribution story as gateway ext-plugin jars);
  • MetadataExecutorSubscriber invokes matching provisioners after ShenyuClientRegisterService#register(MetaDataRegisterDTO) completes;
  • Failures are logged and isolated, so built-in registration is never affected;
  • With no implementations registered, behavior is unchanged.

A minimal implementation sketch is ready and tested locally (SPI + wiring in RegisterCenterConfiguration / RegisterClientServerDisruptorPublisher / MetadataExecutorSubscriber + unit tests). I'm willing to submit a PR.

Related gaps observed while integrating a custom auth plugin

  1. plugin row must be inserted manually (no UI/API provisioning for out-of-tree plugins);
  2. namespace_plugin_rel must be inserted manually, otherwise the plugin is invisible in the admin plugin list;
  3. Button permissions must be inserted manually, otherwise no "add" buttons render on the plugin page;
  4. Selector/rule must be created manually (only divide auto-creates them from client registration).

Related work

  • #8199 / #7294 - plugin store / out-of-tree plugin infrastructure: this hook is the admin-side piece that out-of-tree plugins will need;
  • #8301 - selector configuration export (adjacent provisioning topic).

Chrisp12138 avatar Nov 20 '26 01:11 Chrisp12138