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:

  1. 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.
  2. 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.

Preview as Me: Page Editor Ribbon
The new Preview as Me button in the Page Editor ribbon.

Installation

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:

  1. Start Menu ‘Preview as Me’ button
  2. Content Editor ‘Preview as Me’ button in the Publish ribbon.
  3. Page Editor ‘Preview as Me’ button as an option under the existing Preview button.
  4. Sitecore.AuthenticatedPreview.dll in the application ‘bin’ folder
  5. App_Config\Include\Sitecore.AuthenticatedPreview\Sitecore.AuthenticatedPreview.Commands.config

The Sitecore Client should restart and you will have the button options available to you.

Preview as Me: Content Editor Ribbon
The new ‘Preview as Me’ button in the Content Editor ribbon.
Preview as Me: Desktop Applications
The new ‘Preview as Me’ Desktop Application button.

The Future?

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!

4 Comments

    1. Hello Jose, this has been tested on Sitecore 6.6, 7.2, and 7.5. Functionally, it should work with 7.0 and I have listed it as compatible with 7.0 on the marketplace.

      If you run into any issues, let me know!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s