This server will be upgraded at 3pm Sydney time on December 3rd (December 2nd, 8pm PST) and will be down for up to 30 minutes.

Macro Security Plugin

Description | Compatibility | Usage | Administration | Plugin developers | Examples | Implementing macros | Live-template | Release history | Open Issues
Name Macro Security Plugin
Vendor Bob Swift and other contributors
Authors Bob Swift
Homepage http://confluence.atlassian.com/x/bYAsAg
Issue Management http://developer.atlassian.com/jira/browse/CMSP
Continuous Integration n/a
Categories Admin Macros
Most Recent Version 1.0.0
Availability Confluence v2.5.2 to v2.10
State Stable
Support Unsupported Plugins
License Freeware / Open Source (BSD)
Price Free
Release Docs http://confluence.atlassian.com/x/bYAsAg
Java API Docs n/a
Download Source http://svn.atlassian.com/svn/public/contrib/confluence/macro-security-plugin/trunk
Download JAR macro-security-plugin-1.0.0.jar

Description

Provides security control to restrict powerful macro capabilities to trusted users. Many powerful macros are available that can provide content and capabilities that improve productivity for Confluence users. However, in many cases, these capabilities need to be reserved for trusted users while still allowing other users the ability to view the content created with these macros. How can this be accomplished? Macro security provides the ability for administrators to easily implement and control this capability. This plugin, together with the appropriate enablers for plugin developers, provides the following capabilities:

  1. Restrict macro use to trusted users
  2. Restrict specific macro capabilities (parameters) to trusted users
  3. Restrict macro use to within global or space templates
  4. Configuration at the macro and parameter value level
  5. Simple configuration based on Confluence users and groups
  6. Controlled by normal Confluence page edit restrictions


While macro security has been built into many macros for over two years, this plugin externalizes the configuration and control allowing for dynamic changes. It also adds new capabilities and improves the implementation. If you are using a version of a plugin older than when support was added for the independent macro security plugin, see earlier versions of this page for documentation. The page history together with and the community discussion at Security documents the evolution of the support.

Download statistics (as an independent plugin)

Date 2008-Jun 2008-Jul 2008-Aug 2008-Sep 2008-Oct 2008-Nov 2008-Dec
Hits 75 59 44 66 48 43 5

Compatibility

Plugin 2.5 2.6 2.7 2.8 Tested releases
1.0.0 2.5.2, 2.7.1, 2.8

Related information

Usage

Macro security is based on only allowing restricted macros on pages that have edit permissions that prevent unauthorized users from changing the macro usage. Trusted uses are given the control to ensure proper usage of macro capabilities. Restricted macros will fail to render if the page permissions do not conform to the security setting for the macro. All page permissions defined for a page must be part of the configured macro security setting for the macro to be authorized. At least one page permission is required. Multiple page permissions are allowed and each is checked to ensure the group or userid is authorized by the macro security configuration. Each macro on the page determines authorization according to its configured setting.

Authorized users

  • A user authorized to use a restricted macro simply edits the page as normal. Prior to previewing or saving the page, the user must add a page permission that matches one of the groups or users listed as authorized for the macro. Save the page and then continue editing as normal.
  • All users authorized to view the page see the full rendered content as one would expect.

Unauthorized users

  • A user edits the page as normal. If the user includes a restricted macro that the user is not authorized to use, then when the page is rendered, the restricted macro will give a macro error and not perform any further processing.
  • Confluence prevents users from adding a page permission so that current page author is not allowed to edit the page. Once the page has a page permission that includes the unauthorized user, macro security will prevent rendering.

Example

  • If the sql-query macro has a security setting that specifies the group SQL-experts, then only users in the SQL-experts group will be able to edit pages the successfully render the sql-query macro. Each of those pages must have a page edit permission of SQL-experts.

Administration

An administrator must configure macro security for the installation. This is done by clicking on the Configure link for the plugin. This allows for macro security to be enabled or disabled globally and to dynamically load the security settings from a property file on the Confluence server. The security file can be anywhere on the server, the default location is the Confluence home directory.

Migration

The previous macro security implementation required the macro security property file to be located in the home directory. For migration purposes, it is recommended to continue to use the same file until all macro security implementing macros are upgraded to use the macro security plugin and the dynamic configuration capability.

Plugin developers

  • Each protected macro implements a common checking function that validates that the macro usages allowed. A macro exception is generated for unauthorized use.
  • More information will be provided soon

Examples

  • HTML Plugin - HTML macro is only enabled on pages that can be edited by confluence-administrators
    html=confluence-administrators
    
  • Beanshell Macro is only enabled on pages that can be edited by confluence-administrators or confluence-programmers
    beanshell=confluence-administrators, confluence-programmers
    
  • SQL Plugin - this is a more complex example. In this case, the key control point is the datasource parameter. This controls access to database information that needs to be controlled depending on the database and the permissions used to access it.
    • Allow the sql macro to be used by everyone
    • Restrict the ConfluenceDS data source to confluence-administrators
    • Restrict the TestDS data source to test-team
      sql=*ANY
      sql.datasource.ConfluenceDS=confluence-administrators
      sql.datasource.TestDS=test-team
      

Implementing macros

Many macros are enabled for macro security, but not all are enabled to the macro security plugin. The next release of each of these macros will upgrade to this level of support. denotes macros that have a version available with the upgraded support.

Live-template

The live-template macro (part of the Scaffolding Plugin) provides powerful capabilities for global and space administrators to provide template based content. Administrators control the parameterized content of the page. Users can control the parameters. This is an ideal mechanism for providing and controlling security restricted macro content within less restricted pages. The latest release of the Scaffolding Plugin (SCAFF-196) implements support that enables macro security based plugins to provide this advanced support. It allows administrators to have restricted macros within global or space specific live templates without requiring that the resulting page have page edit permissions. Administrators will have the ability to control each macro and parameter combination for live-template use where the template is global or from specific spaces.

Example live-template authorization

sql-query&live-template.datasource.TestDS=*global, QA-space

Release history

Version Date State License Price
Show description 1.0.0 (#1) 24 Apr 2008 Stable Freeware / Open Source (BSD) Free

Release Notes

Jira Issues
Key Priority Summary Updated asignee Reporter Status
CMSP-1 Major Initial release Apr 26, 2008 Bob Swift Closed

Contributors

  • Bob Swift — Developer

Open Issues

Labels

security security Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Apr 15, 2007

    Bob Swift says:

    There seems to be an incompatibility problem with 2.4.x when using this capabili...

    There seems to be an incompatibility problem with 2.4.x when using this capability relating to Changes to the Page Permission API in Confluence 2.4. The errors occur for any macro that has been configured to enforce macro security. Atlassian has looked at this and believe the referenced method is still in the distribution and should not cause an error. A work around is to disable macro-security checking. The following is an example of the error that has appeared on at least 2.4.4 and 2.4.5.

    Error formatting macro: html: java.lang.NoSuchMethodError: com.atlassian.confluence.core.ContentEntityObject.getContentPermission(Ljava/lang/String;)Lcom/atlassian/confluence/core/ContentPermission;
    
    1. Jun 21, 2007

      Jim LoVerde says:

      Any idea whether work is being done to resolve this issue? And is there a JIRA ...

      Any idea whether work is being done to resolve this issue? And is there a JIRA issue open for it? I've had to temporarily disable macro security in order to get around this issue (on version 2.5.3 atm).

      1. Jun 21, 2007

        Bob Swift says:

        I have given up on Atlassian resolving the issue. I have upgraded to 2.5.2 and ...

        I have given up on Atlassian resolving the issue. I have upgraded to 2.5.2 and have temporarily disabled the security as well. The Java Scripting Plugin have been updated and the others should be there in a couple of weeks.

  2. Jun 20, 2007

    Sven Saschek says:

    Version 1.3.0. Installation of the scriputil plugin fails There were errors wh...

    Version 1.3.0. Installation of the scriputil plugin fails

    • There were errors when uploading this plugin: com.atlassian.plugin.PluginParseException: File atlassian-plugin.xml not found in plugin JAR [....../temp/scriptutil-1.3.0.jar]
    1. Jun 20, 2007

      Bob Swift says:

      You do not install this, it is bundled with other plugins.

      You do not install this, it is bundled with other plugins.

  3. Aug 07, 2007

    Brian M. Thomas says:

    A comment from the sample macro-security.properties file: # If the proper...

    A comment from the sample macro-security.properties file:

    # If the property file exists, then it MUST specify something for each
    #   restricted macro, otherwise macro use is not authorized

    This page does not make this plain, and it should (Of course, with my comment, now it does ).

    This is, to my InfoSec-saturated brain, the appropriate way to proceed, and I applaud it.

    But it raises a question: How, other than waiting to find it out the hard way, can an admin know which macros require entries here? It does not appear to be a standard feature of the macro user guides to document this dependency, as I don't recall reading about it in any of them. It surely would have been desirable, because I was on the point of disabling the SQL macro plugin because of its risks before our user community grew too large (we've got about 10% participation a week after announcing it to 2000 people, with plans to roll it out in roughly exponential steps over the next few months to a final target population of about 300K, so you get an idea of the urgency).

    In fact, the first time I had any notion of macro-security.properties – even after having researched and installed many macro plugins and reading many Confluence documents – was when I read the startup warning message in the log saying there wasn't one, and only then did I come seeking this page.

    The sample file does contain a goodly number of entries, and one comment even lists "Current restricted macros". May I presume, at any time I retrieve this sample file, that the list is indeed current (with respect to the macros documented here and on CustomWare's and Adaptavist's sites), or at the least that any macro that is installed and disabled as a result of having no entry will give a warning message in the log? That at least will prevent my greatest fear from being realized:

    ... 200 technically-clueless production users descending on me, asking why a little pink error message shows up on their favorite page instead of the content they were expecting..._

    1. Aug 07, 2007

      Bob Swift says:

      Brian, all good points. Don't have the time to provide detail response on these...

      Brian, all good points. Don't have the time to provide detail response on these right now. I will try to get back to this soon. Thanks for commenting and thus documenting more of this!

      1. Feb 17, 2008

        Bob Swift says:

        I have added a few of your notes to the main document to make it clearer. There...

        I have added a few of your notes to the main document to make it clearer. There needs to be some improvements in the documentation for each macro that uses this capability. Some have this page explicitly linked, but some do not. I will try to improve that next time macros get updated. The example file is pretty accurate since I am involved in development of most macros that implement this capability, but it is open for mistakes of omission. The intention is to have the example file accurate with the current implementation. If a new restricted macro is added, it is still goodness to not have it work until explicitly authorized - hopefully the macro documentation will alert administrators appropriately. There is no warning in the log if there are missing entries.

  4. Feb 18, 2008

    David Dembo says:

    If I understand the documentation correctly, the way this works is that: Restr...

    If I understand the documentation correctly, the way this works is that:

    • Restricted Macro A can be used by permitted User A on Page A that is restricted to editing by that user.
    • If Macro A is used by User A on Page B that is not restricted, the macro will fail even though it is used by a permitted user.

    Is that correct?

    What I'm after is basically something that checks the restrictions at the time that a page is saved (or previewed)... if the user performing the action is permitted, the macro would be evaluated and the content rendered. If the user is not permitted:

    • If the macro was previously added by a permitted user and there has been no change to its body or parameters (e.g. a non-permitted user has just changed some surrounding text), the macro would be evaluated and the content rendered.
    • If the macro has been changed by a non-permitted user in any way, then the curly brackets would just be escaped so that the macro is not evaluated or rendered.

    As far as I can tell, this would still be a secure model, while allowing a lot more flexibility - restricted macros could even be used in spaces that can be edited by 'Anonymous'.

    Does anyone know of a way to achieve something like this?

    1. Mar 15, 2008

      Bob Swift says:

      Sorry, missed this update. Your understanding is correct. Your suggestion for s...

      Sorry, missed this update. Your understanding is correct. Your suggestion for somehow remembering the signature of the macro as edited by valid users is interesting, although I don't know how to do it at the moment. Please feel free to write up an issue and any proposals on how to do it. Here are a few notes in the meantime.

      1. It is pretty easy to put a page segment that contains the restricted macros on a page and included them on the general page
      2. An enhancement that works better with live-templates and potentially user macros may help as well
      1. Mar 16, 2008

        David Dembo says:

        No worries, thanks Bob!

        No worries, thanks Bob!

        1. Mar 16, 2008

          David Dembo says:

          Just noticed there's no issue tracker for this, so I'll share a couple of though...

          Just noticed there's no issue tracker for this, so I'll share a couple of thoughts I had here:

          • Could perhaps generate a 'signature' based on the parameters/body
          • RTE is likely to cause issues
          • Possibly intercept the default action(s) that occur when a page is saved/previewed/etc, checking the original markup vs submitted markup for any differences.
          • Possibly implement via a {secure-content} (or similar) macro... regular content as well as secure macros could be protected in this manner

          A more involved alternative (but IMO much-needed functionality) - add a couple of new permissions to Confluence... 'can use regular macros', and 'can use restricted macros'

          • Global, space and page-level permissions would be fantastic.
          • Would need a mechanism to restrict individual macros - suggest using the 'Plugins' page in admin console... all macros could have a 'Restricted'/'Unrestricted' toggle underneath 'Enable'/'Disable'.
          • Alternatively, rather than a broad all-or-nothing approach, restrictions could be specified per-macro via a rules-based approach - would probably need a more central method of managing this, e.g. a new page in the admin console.
          • Either approach could be made so that plug-in developers could use provide more granular restrictions via the same mechanism... e.g. individual functions/UI elements/parameters/etc
  5. Jun 20

    Liam Jones says:

    Ghaa! A point worth noting that I just had an epiphany for after 1/2 an hr of b...

    Ghaa!

    A point worth noting that I just had an epiphany for after 1/2 an hr of being thoroughly stumped; sql. restrictions in the properties file don't cover the sql-query macro!

    >.<

    If you want to secure some sources from {sql-query} use as well as {sql} you need your macro-security.properties file to contains a rule that reads sql-query.dataSource=... as well as one for the same source which is just sql.dataSource=...!

    1. Jun 20

      Bob Swift says:

      Yes, each individual macro is controlled separately. sql-query was added after t...

      Yes, each individual macro is controlled separately. sql-query was added after this page was created, so not explicitly discussed. In general, you want the strongest level of security on the sql macro, but you may want to allow more people for specific datasources for the sql-query macro as it is read only.

      1. Jun 20

        Liam Jones says:

        Yeah, I made a silly assumption that the sql= rules were talking about the SQL p...

        Yeah, I made a silly assumption that the sql= rules were talking about the SQL plugin package in it's entirety. It's all working much better now!