Skip to content

Authorization plugins can't see the permissions extensions declare on their API operations #593

Open

Description

@pacmano1

An authorization plugin (an AuthorizationController from an extension's controllerClasses) learns which permission a core API operation needs from OperationUtil.getOperationNamesForPermission. It has no way to learn the permission an extension declares on its own servlet operations.

  • OperationUtil only scans com.mirth.connect.client.core.api.servlets (OperationUtil.java:72) and returns bare operation names.
  • Extension operations reach isUserAuthorized as an ExtensionOperation named <extension name>#<operation> (ExtensionOperation.java:27), so a bare name wouldn't match anyway.
  • The only channel from an extension to the controller is ServicePlugin.getExtensionPermissions, passed to addExtensionPermission (DefaultExtensionController.java:407). It's built for permissions a plugin defines for itself. No bundled connector uses it: TcpServicePlugin.getExtensionPermissions returns null, and the others have no service plugin.

So a @MirthOperation(permission = ...) on an extension's operation, like the connector services in #588, never reaches the controller. With the default controller that doesn't matter, since it allows everything. With an authorization plugin, those operations fall through to whatever the plugin does with unknown operations.

Measured with released role-based-access-control 1.3.0 on a build of #588 at c4ec1c2, signed in as a role with only View Dashboard: getProperty, which #588 labels in the core API, was refused ("Missing permission: viewServerSettings"). The Document Writer test, which #588 labels manageChannels, and the JMS template list, labelled viewChannels, both returned 200, and the plugin logged each as an operation with no permission ("allowing unknown operation 'Document Connector Service#testWrite'").

role-based-access-control works around it now (diridium-com/role-based-access-control#63): it reads every enabled extension's registered servlet interfaces itself and assumes the runtime name starts with the interface's PLUGIN_POINT constant. That's a naming convention, not part of the registration, and every authorization plugin would have to repeat it.

Proposal: when the engine collects an extension's SERVLET_INTERFACE registrations (as MirthWebServer does at MirthWebServer.java:573), hand the controller each operation's declared permission under the name the operation is delivered with. For example, a new AuthorizationController method with a no-op default, called next to addExtensionPermission. The extension name then comes from the engine instead of a constant's name.

Related, small: TcpConnectorServletInterface.PLUGIN_POINT is "HTTP Connector Service" (TcpConnectorServletInterface.java:40), so TCP's and HTTP's testConnection arrive under the same name.

Line numbers are at 4878ed1.

Co-authored with Claude Code.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions