Plugin access control

Hi. I have implemented a somewhat dangerous feature for the next release of dashboard. The feature is called "Command Sensors" and will display the stdout/stderr output of configured shell commands in dashboard widgets. The purpose of this feature is to allow creative users to access and display pretty much any info available thru the platform where OctoPrint runs (shell commands, scripts, etc...). Each command is executed by the plugin backend and will run in a shell with the privileges of the octoprint service via a python subprocess.Popen. This flexibility comes with the downside that given access to the plugin configuration, any shell command can be executed...

Here is what it currently looks like:

Screenshot 2020-06-04 at 18.05.34

I'm not up to speed with the Access Control improvements in 1.4 so my question is what you think would be the proper way to secure this feature while maintaining most of the flexibility it provides. Any ideas?

Because of the danger with this I would think you would want to implement a custom access permission and then the user has the ability to enable that permission within the user configuration. By making that a manual process you are basically telling them, this is dangerous and is a kind of opt-in scenario.It even has a dangerous flag that allows you to state it as such.

https://docs.octoprint.org/en/master/plugins/hooks.html#octoprint-access-permissions

I haven't worked with it personally, but I assume you can then do a knockout binding on the custom permission, similar to this...

Perfect. Thanks!

I also need custom permissions for my PrintJobHistory (readonly/edit a job) and found the above link,
BUT you keep in mind that this is not available at OP 1.3.x. It only works with 1.4.x

Maybe a good approach to "push" the users to upgrade -> less testing effort for plugin-develeopers.

Or @jneilliii, @Stefan_Cohen do you test your plugins with all combinations of OP1.3/1.4 Py2/3 ???

I don't, I always test in latest OctoPrint personally. I don't think any of my plugins as of yet have those in them, so hasn't been a problem for me yet.

Same here. Only latest.