Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Prevent admin user from disabling servlet-filter module.

Ricardo Herrera September 18, 2019

We're developing a plugin which core functionality relies on a servlet filter, this however can be disabled from upm page expanding modules of our plugin. Is there a way to hide the disable button for this specific servlet filter?

1 answer

1 accepted

0 votes
Answer accepted
Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 18, 2019

An admin can always disable any module that is not flagged as a "system essential" module.  You'd need to change the core code of Jira to tell it that the servlet filter is such a module, there's no way to protect it from the outside.

Best you can do is detect it as your app loads and throw an error that just stops it loading/enabling and tells the admin why it's refusing to load.

Ricardo Herrera September 18, 2019

Thanks for the response @Nic Brough -Adaptavist-, let's say plugin is installed for the first time with this module enabled, so everything is good; but then, admin user decides to disable it. Is there a way to be notified of this event? If so, could I programmatically disable the whole plugin?

 

Thanks in advance.

Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 18, 2019

That would be a lot nicer than a simple crash from your app.  There may be a way to write a listener that catches "plugin/module disabled" and causes yours to be disabled if they hit that one, but I'm really not sure.

Ricardo Herrera September 18, 2019

Thanks Nic! this is how I finally solve it:

public class PluginModuleEventAware implements DisposableBean, InitializingBean {

private final EventPublisher eventPublisher;
private final PluginController pluginController;

public PluginModuleEventAware(EventPublisher eventPublisher, PluginController pluginController) {
this.pluginController = pluginController;
this.eventPublisher = eventPublisher;
}

@Override
public void afterPropertiesSet() throws Exception {
eventPublisher.register(this);
}

@Override
public void destroy() throws Exception {
eventPublisher.unregister(this);
}

@EventListener
public void onModuleDisabledEvent(PluginModuleDisabledEvent moduleDisabledEvent) {
if (moduleDisabledEvent.getModule().getKey().equals("my-core-filter")) {
pluginController.enablePluginModule(moduleDisabledEvent.getModule().getCompleteKey());
}
}

}

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events