Div |
---|
|
On this page Table of Contents |
---|
maxLevel | 1 |
---|
exclude | On this page |
---|
type | flat |
---|
separator | pipe |
---|
|
|
Basic Use
...
...
...
...
Parameters
...
Parameters
The Macro Security macro accepts 3 parameters.
Table plus |
---|
highlightColor | #ffffec |
---|
rowStyles | background:#f0f0f0;color:#222;font-size:14px;border-bottom:black 2px solid;border-top:black 2px solid;, |
---|
style | background-color:white; |
---|
autoNumber | true |
---|
|
| | | |
---|
name | <required> | Macro name | The name to use as the primary lookup in the macro security configuration to see if this particular use is allowed. | parameter | | Parameter name | Used to further qualify the security lookup when a Parameter Restriction is defined. Leave blank if not needed. Normally represents a macro parameter name. | parameterValue | | Parameter value | Used to further qualify the security lookup when a Parameter Restriction is defined. Leave blank if not needed. Only valid if a parameter name is provided. Normally represents a macro parameter value when specific values need to have secured use. |
|
Example
...
The primary use is in a user macro or private macro. Here is a simple user macro example. This macro will only continue to process and render content if the security configuration and context allow.
...
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:
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:
Code Block |
---|
restricted = confluence-administrators |
- 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.
Image Added
In the example above:
Table plus |
---|
columnStyles | width:70%,width:30% |
---|
columnTypes | S,S |
---|
style | table-layout: fixed; width: 100%; |
---|
|
These line(s): | Mean... |
---|
## Macro title: Restricted ## Body processing: No macro body ## ## Developed by: Bob Swift Atlassian Add-ons ## Date created: 11/23/2015 ## Installed by: <your name>
## This is a user macro the demonstrates how to incorporate ## Macro Security into a user macro.
| These are comments (as denoted by the "## " at the start of the line) that document the purpose and configuration of the user macro. | ## Check for authorized use #set ($securityMessage = $action.getHelper().renderConfluenceMacro("{macro-security:restricted}"))
| The #set line indicates to invoke (execute) the Macro Security macro, sending it its required name parameter which is the name of the user macro (restricted, in this example). This looks up the configuration of the "restricted" user macro in the Macro Security properties file and compares it to the "edit" page restrictions on the Confluence page on which the user macro is being used. The value returned by the Macro Security macro is placed into a variable named $securityMessage . This will reflect an empty string if the security configuration and "edit" page restriction conditions are met; otherwise it will return an error string that indicates the reason for the error. | #if ($securityMessage =="") ## There are no security issues, so do whatever the macro's normal ## processing would be here This is the result of the macro #else ## Just send out the security error message as is. $securityMessage #end
| The first line (#if...) determines if the Macro Security macro returned an error string. If it did not, then the "normal" processing statements will be executed. If it did return an error string, the "else" condition is executed to display the error message itself. |
|
HTML Comment |
---|
|
Example 2 - Advanced UseThis example demonstrates how to add support for a user macro that uses both Use Restrictions and Parameter 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 and Parameter Restrictions on the Understanding How Macro Security Works page. There are two steps: Editing and reloading the Macro Security properties file so it contains both a Use Restriction entry and Parameter Restriction for the user macro. This entry might look like this: Code Block |
---|
restricted = confluence-administrators
restricted.maxEntries = confluence-administrators |
- 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.
{macro-security:restricted|parameter=myRestrictedParameterName}
|