Using the Macro Security Macro to Control User Macros

Overview

The macro-security macro is primarily a tool for administrators to enable usage control of user macros. When included in the logic of a user macro, it can be used to control who can edit content containing the user macro in a manner very similar to how other macro security controlled macros work.

Macro Security macro

The Macro Security macro is generally not used directly on a page. Instead, it is used within a user macro to enforce any restrictions coded for that user macro within the Macro Security properties file configured by a Confluence Administrator.

For testing purposes, you may wish to temporarily add the Macro Security macro to a page. To do this, you will need to type the entire markup shortcut in the editor to insert it, as the Macro Security macro is deliberately not visible in the Macro Browser.

Markup Shortcut{macro-security}

Screenshot

 On This Page:

Parameters

The Macro Security macro accepts 3 parameters.

Example 1 - Basic Use

This example demonstrates how to add support for a user macro named "restricted" that uses only Use Restrictions. A trusted user or group will be able to add this user macro to a page; other (non-trusted) users and groups will be able to view the page but not edit it. Learn more about Use Restrictions on the Understanding How Macro Security Works page.

There are two steps:

  1. Editing and reloading the Macro Security properties file so it contains a Use Restriction entry for the user macro. This entry might look like this:

    restricted = confluence-administrators
  2. Coding the user macro so that it invokes the Macro Security macro and then directs its processing based on what is returned from the Macro Security macro.

In the example above: