Blocking history of pages for anonymous users

Katherine Katherine
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 24, 2011

I need to block the change history (from the tools menu) for anonymous users. Is there a way to do this?

2 answers

3 votes
GuilhermeA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 3, 2013

Hello Katherine,

Intrigued by your request I have made a workaround using Velocity in order to avoid this to happen. We will need to modify the viewpreviousversion.vm from <confluence-install>/confluence/pages/ you can save a copy and edit all the content to the code below. Please change the custom message on the last lines accordingly to your needs as well. :)

&lt;html&gt;
    &lt;head&gt;
        &lt;title&gt;$action.getText("title.view.previous.versions") - $!page.title&lt;/title&gt;
    &lt;/head&gt;

    #applyDecorator("root")
        #decoratorParam("helper" $action.helper)
        #decoratorParam("mode" "view-information")
        #decoratorParam("calendar-width" "200px")
        #decoratorParam("context" "$action.page.type")

		## PERMISSION TO CHECK IF USER IS ANONYMOUS, IF ANONYMOUS THERE IS NO HISTORY FOR IT :)
		#if ($action.remoteUser != $null)
		
        #requireResource("confluence.web.resources:page-history")
        &lt;form name="diff" method="GET" action="diffpagesbyversion.action"&gt;

            &lt;input type="submit" value="$action.getText('compare.selected')"&gt;
            &lt;input type="hidden" name="pageId" value="$action.pageId"&gt;

            &lt;style&gt;
            .tableview td {white-space:nowrap; vertical-align:top;}
            &lt;/style&gt;

            &lt;table id="page-history-container" width="100%" cellspacing="0" class="tableview"&gt;
                &lt;tr&gt;
                    &lt;th&gt;&amp;nbsp;&lt;/th&gt;
                    &lt;th&gt;$action.getText("heading.version.number")&lt;/th&gt;
                    &lt;th&gt;$action.getText("heading.version.date")&lt;/th&gt;
                    &lt;th&gt;$action.getText("heading.comment")&lt;/th&gt;
                    #if( $action.isRevertPermitted())
                    &lt;th&gt;$action.getText("heading.operations")&lt;/th&gt;
                    #end
                &lt;/tr&gt;
                &lt;tr id="rowForVersion$page.version"&gt;
                    &lt;td width="%1"&gt;&lt;input type="checkbox" name="selectedPageVersions" value="$page.version" #if ($action.isSelectedVersion($page.version)) checked #end&gt;&lt;/td&gt;
                    &lt;td align="left"&gt;
                        &lt;strong&gt;
                        &lt;a href="viewpage.action?pageId=$page.id"&gt;$action.getText("current.version")&lt;/a&gt;
                        (v. $page.version)
                        &lt;/strong&gt;
                    &lt;/td&gt;
                    &lt;td align="middle"&gt;
                        &lt;strong&gt;
                        $dateFormatter.formatDateTime($page.lastModificationDate)
                        &lt;/strong&gt;
                    &lt;/td&gt;
                    &lt;td style="white-space:normal;"&gt;
                      &lt;strong&gt;#usernameLink ($page.lastModifierName)&lt;/strong&gt;#if ($page.versionCommentAvailable):
                        &lt;br&gt;&lt;span class="change-comment"&gt;$page.renderedVersionComment&lt;/span&gt;#end ## Only put in a break if there's a comment
                    &lt;/td&gt;
                    #if( $action.isRevertPermitted())
                    &lt;td&gt;&amp;nbsp;&lt;/td&gt;
                    #end
                &lt;/tr&gt;
                #if( $previousVersions )
                    #foreach( $oldPage in $previousVersions )
                        &lt;tr id="rowForVersion$oldPage.version"&gt;
                            &lt;td width="%1"&gt;&lt;input type="checkbox" name="selectedPageVersions" value="$oldPage.version" #if ($action.isSelectedVersion($oldPage.version)) checked #end&gt;&lt;/td&gt;
                            &lt;td align="left"&gt;
                                &lt;a href="viewpage.action?pageId=${oldPage.id}"&gt;v. $oldPage.version&lt;/a&gt;
                            &lt;/td&gt;
                            &lt;td align="middle"&gt;
                                $dateFormatter.formatDateTime( $oldPage.lastModificationDate )
                            &lt;/td&gt;
                            &lt;td style="white-space:normal;"&gt;
                              &lt;strong&gt;#usernameLink ($oldPage.lastModifierName)&lt;/strong&gt;#if ($oldPage.versionCommentAvailable):
                                &lt;br&gt;&lt;span class="change-comment"&gt;($oldPage.renderedVersionComment)&lt;/span&gt;#end ## Only put in a break if there's a comment
                            &lt;/td&gt;
                        #if( $action.isRevertPermitted())
                            &lt;td align="middle"&gt;
                                #if ($oldPage.version&gt;0)
                                    &lt;a href="revertpagebacktoversion.action?pageId=$page.id&amp;version=${oldPage.version}"&gt;$action.getText("restore.this.version")&lt;/a&gt;
                                #end
                            &lt;/td&gt;
                        #end
                        &lt;/tr&gt;
                    #end
                #end
            &lt;/table&gt;
        &lt;/form&gt;
        &lt;p&gt;&lt;a href="${req.contextPath}/pages/viewinfo.action?pageId=${page.id}"&gt;$action.getText('return.to.page.info')&lt;/a&gt;&lt;/p&gt;
		#else
		## CUSTOM MESSAGE TO ANONYMOUS USER
		&lt;ul&gt;Unfortunately as Anonymous you lack permission to use the page History, for further information please contact Confluence Administrators&lt;/ul&gt;
		#end
    #end
&lt;/html&gt;

Hope this helps you get on the right track. If you need any tweak let me know!
Cheers,
Guilherme

Sam
Contributor
November 21, 2018

Hi Guilherme,

Does this solution still works for Confluence server 5.9.9
https://confluence.atlassian.com/confkb/how-do-i-prevent-anonymous-users-from-using-page-history-317196367.html ?

0 votes
Giuliano C_
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 2, 2013

Hi Katherine,

Unfortunately, from my thoughts Confluence doesn't work with this Feature, since you block anonymous to view a page, you will block him to see all content, you are not able just to block the history of the page. However, if you wish, we can create a Feature Request for you and see how it will goes.

Thanks a lot for your comprehension.

Kind Regards,

Giuliano Tenedini

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events