[[PageOutline(2-5,Contents,pullout)]] = Protect parts of a wiki page from invalid access == Description === Wiki With this macro it is possible to limit access to parts of a Trac wiki page. A protected part has the following syntax: {{{ {{{ #!protected #:This is what an unauthorized user sees (optional) This is what an authorized user sees }}} }}} A protected part can use `!protected`, `!protected-red`, `!protected-blue` or `!protected-green` to provide access restrictions on different levels. Users will only see these protected sections when they have the permissions `PROTECTED_VIEW`, `PROTECTED_RED_VIEW`, `PROTECTED_BLUE_VIEW` or `PROTECTED_GREEN_VIEW` respectively. A `!protected` part will be rendered with a red line to the left, a `!protected-blue` part will be rendered with a blue line to the left, etc. '''Note''': when searching though the wiki the protected parts are still shown. === Attachment Attachments are protected when the key-string "!protected", "!protected-red", "!protected-blue", or "!protected-green" is present in the attachment's description. Users will only see these protected attachments when they have the permissions `PROTECTED_VIEW`, `PROTECTED_RED_VIEW`, `PROTECTED_BLUE_VIEW` or `PROTECTED_GREEN_VIEW` respectively. To enable the attachment protection the conf/trac.ini must be modified. Add the ProtectedAttachmentPolicy to the permission_policies: {{{#!ini [trac] permission_policies = ProtectedAttachmentPolicy, DefaultPermissionPolicy }}} === Improvements * SECURITY VIOLATION: When searching through the wiki protected parts are searched and shown * Filter out hidden parts when editing a wiki page * Supply an admin feature to add/edit protected-xxx * Supply an admin feature to edit the style/template for a permission part * Give visual feedback for unauthorized attachments in the attachment list == Bugs/Feature Requests Existing bugs and feature requests for ProtectedMacro are [report:9?COMPONENT=ProtectedMacro here]. If you have any issues, create a [/newticket?component=ProtectedMacro new ticket]. [[TicketQuery(component=ProtectedMacro&group=type,format=progress)]] == Download Download the zipped source from [export:protectedmacro here]. == Source You can check out ProtectedMacro from [/svn/protectedmacro here] using Subversion, or [source:protectedmacro browse the source] with Trac. == Example {{{ {{{ #!protected #:This will only be visible to those that do not have the PROTECTED_VIEW permission This will only be visible to those that have the PROTECTED_VIEW permission Will show all content with a red line to the left }}} {{{ #!protected-red #:This will only be visible to those that do not have the PROTECTED_RED_VIEW permission This will only be visible to those that have the PROTECTED_RED_VIEW permission Will show all content with a red line to the left }}} {{{ #!protected-blue #:[[Include(wiki:RestrictedSection)]] This will only be visible to those that have the PROTECTED_BLUE_VIEW permission. Those that do not have this permission will see the wiki page called RestictedSection }}} }}} == Recent Changes [[ChangeLog(protectedmacro, 3)]] == Author/Contributors '''Author:''' [wiki:frayja] [[BR]] '''Maintainer:''' [[Maintainer]] [[BR]] '''Contributors:'''