Drupal 7 Protected Pages Module

By adam
Fri, 2014-11-21 10:48
Daily Dose of Drupal Episode #180

Share with Others

In this video we look at the Protected Pages module for Drupal 7. This module allows for password protection on paths in Drupal. In other words, this module will prompt a visitor to a specific page to enter a password before they are able to see the content.

This is one of those modules that exists to just make this use case simple. There are a ton of other ways to accomplish this with permissions and roles in Drupal, but it is always nice to have a simple way to accomplish this task.

Let me know of how you have used this module in the past. Do you still use it today? If not, how do you handle this problem?

Hello everybody and welcome to Episode 180 of the Daily Dose of Drupal. I am Adam and today we are going to be looking at the Protected Pages Module. The Protected Pages Module is a module that allows you to provide a password to your customer client and then with the password they can then access the page. Well without that they will not be able to access and instead they’d get a prompt that says Enter Your Password. A couple of different use case I’ll talk about it along the way.

Some of them could be if you obviously just have sensitive information, you only want certain clients to see or for example at Code Karate we could use this for…to put our Cheat Sheets behind this. We only wanted certain people with a password to get that. We could use it for that used case. So a lot of different use cases, also there’s a lot of different options you could use besides this module but this module is quick and easy way to get this done.

Really quick before we jump into the module, again just head on over to codekarate.com, make sure to check out our 5 Secrets to Becoming a Drupal 7 Ninja EBook as well as our Cheat Sheets that are available. We both have one in Git and in Drush so check those out. Alright let’s get started. So for this video I am using 7.24 of the Protected Pages Module, so once you get that downloaded and installed, just head on over to your Modules Page and then enable the Protected Pages Module.

Once you enable, the first thing you’re going to want to do is go to your Permissions and once you’re in Permissions, scroll down to you’ll find the Protected Pages section and in that there’s three different information that you can configure and the one that’s the most important is the middle one here. Access Protected Page Password Screen.

This just allows you to…allows that user to be able to get to that page. Without it you can’t even get to it so it’s kind of defeats the purpose of the Protected Password Module. So I always make sure to check the roles that I want and in those cases I want all my roles anonymous, authenticated and the administration role. Of course you can configure the other ones based on the roles that you might have on your site but for this simple case we’re just going to use those three.

Alright so once you get those Permissions set, go to your Configuration Protective Pages and there’s some settings in here that you can configure. The first one is the protected pages that you want. Protected Pages works off of nodes or pages. So what you can do is you could use a View or you could use Panels or you could just use a regular basic page content type.

In this case I’m just using a basic page and you see that I’ve added one down here, so node/1 is a protected page and if I edit this I would be able to set the password of the page so I’m going to set that here and save it. So anytime I would go to node/1 I should be prompted for a password. You can also see there’s a said email button here, if you click on that you can select recipients and then I’ll show you how you can configure the subject and body here but this is basically email that I’ll send to them. Letting them know, hey you can go to this URL and here’s the password that you need to use to access it or it provides a drop out of a box easy way to contact people that you want to have access to that. If you hover over here to the Settings tab there’s a bunch of different settings that you can configure.

You can use a global password and up here you have a setting that says you only want to allow pure page passwords so that would be individually or you can allow both or you can only allow it global. Of course this would be if you wanted to just have one password for all your protected pages, that’s where you would enter that. This one is the last one and it’s kind of an interesting one. The last one in this section anyway.

The Section Expire Time, as you can see from the description below, this basically is how long the session holds until they re-enter their password. It of course if it’s set to 0 it’s unlimited and the session will never expire but you could set that to 5 minutes, 10 minutes, whatever you prefer. And then the below sections are just…the configurations on different elements within the protected pages settings.

So this will be the email subject, the email content, we also have stuff as far as on the page itself, protected pages…this is like all the prompts. So you can configure all that if you’d like. I’ll not leave them all default. So now if I go over here as a used case and I said I am an individual and I go to node/1 you’ll see that I have a protected page enter passwords. So I have to enter a password but again I would be providing that email and click Authenticate and once I enter the correct password I now can see the content behind that page. So for your eyes only and just show you that is the content that I created. So if I go over here to content, again I was the admin and I see this page, so there you go.

So that’s why I wanted to show them and again this could be anything, this could be a view in there, it could be a panel page, it could be whatever you wanted it to be, it could be an invoice, whatever. Of course right now it just said simple node. Then again if I go back to the page I see the same thing but it’s because I enter the password correctly. So anyway, that is the module, real simple module, not too much to it but it has a definitely some used cases for privacy as well as showing clients specific things.

Alright so that is everything so make sure again to let us know what you think of the module. If there’s any other modules or similar you want us to review, let us know. Otherwise, again head on over to Code Karate and check on what’s going on there and let us know on any other thoughts you have. Alright thanks guys.