Do you secure some of your website content from unauthenticated users? If so, you probably noticed that the default Preview mode isn’t working for you.
Since Sitecore’s preview mode executes as the anonymous user, your secured content becomes hidden from that user. As an author, you need to be able to see what your content looks like, while also testing the security. How do we address this?
One setting to rule them all
Starting in Sitecore 7.2, a new configuration setting named Preview.AsAnonymous has been introduced. The default value (true) provides the classic experience of previewing as the anonymous user that previous versions of Sitecore used. Switching this setting to ‘false‘ will allow users to preview as themselves instead.
This is a great step forward from Sitecore, but it has a few drawbacks:
- The all-or-nothing setting means you can have anonymous or you can have authenticated preview. You cannot choose which you want to use when you are previewing.
- You may require a Sitecore version upgrade. This setting is not available in earlier versions so you cannot use it on an older version of Sitecore.
The Sitecore.AuthenticatedPreview module
As you probably suspected, I’ve tried to put together a solution for this particular problem. In my scenario, I had a client on Sitecore 6.6 that needed the ability to preview content that was secured from the anonymous user. While I could have overridden the default Preview functionality, I decided instead to opt for a solution that gave the choice to the user.
After building this ‘Secure Preview’ fix, I then decided to rebuild it more generically and provide this to the community. Enter the Authenticated Preview module, now available on the marketplace!
From the module description:
This module adds a new ‘Preview as Me’ button that allows authors to choose whether to launch the ‘classic’ Preview mode or launch the new authenticated preview.
Authors can now preview content that has been secured from anonymous users by previewing the page with their own permissions.
The new ‘Preview as Me’ buttons have been added to permit users to continue previewing as anonymous when desirable.
The installation is very simple. Installed as a standard Sitecore package, this will add a single DLL, a configuration file, and 3 new items into your Core database to make the new buttons available to you.
The package will install the following elements:
- Start Menu ‘Preview as Me’ button
- Content Editor ‘Preview as Me’ button in the Publish ribbon.
- Page Editor ‘Preview as Me’ button as an option under the existing Preview button.
- Sitecore.AuthenticatedPreview.dll in the application ‘bin’ folder
The Sitecore Client should restart and you will have the button options available to you.
This simple step forward should allow folks to have the option in their builds for the ‘Anonymous or Me’ scenario. My next step is to build in the ability to choose which user to preview the page with. This will support better analysis of security settings, especially when working with an Active Directory integration.
UPDATE: Previewing as a selected user is now available!