Blocking history of pages for anonymous users

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

2 answers

This widget could not be displayed.

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

This widget could not be displayed.

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
Community showcase
Posted Sep 17, 2018 in Confluence

Why start from scratch? Introducing four new templates for Confluence Cloud

Hi my Community friends!  For those who don't know me, I'm a product marketer on the Confluence Cloud team - nice to meet you! For those of you who do, you know that I've been all up in your Co...

602 views 8 6
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you