Content Access Control on Developer Portal using Taxonomy Access Control

You may want to read the content access overview before reading this document.

Problem

When creating content on your Apigee Developer Portal, sometimes you need to lock down documentation so that only certain groups of developers can see it. For example, if you may have “beta” APIs which are only available to certain developers. Also, if the API becomes public, you need to be able to modify the permissions of those pages so that all developers can view them.

Solution

By using Drupal taxonomy and taxonomy access modules, you can group (or label) your content with different terms, then define access for each term.

For example, let’s say you want to restrict access to documentation in the following manner:

  1. Some documentation is viewable by anyone
  2. Some documentation is hidden to anyone that is anonymous, or in other words you have to be logged in to see the documentation
  3. Some documentation can only be seen by “Internal” developers
  4. Some documentation can only be seen by developers in the “beta” program

Step 1: Create Your Taxonomy and Terms

For our example, you need to create a new taxonomy vocabulary which you will use to label content you create. We will create a new taxonomy vocabulary named “Page Access” which will contain the following terms in it:

Vocabulary: Page Access

  • Anonymous
  • Authenticated
  • Internal Developers
  • Beta Developers

To create the vocabulary, log in as an administrator and click on Structure > Taxonomy > Add vocabulary, and name the vocabulary and give a description, then click Save:

You will now see your new vocabulary listed. Click on Add Terms and enter in the first term name “Anonymous”, then click Save. Continue to add all the terms in the same manner. When you are done, click on the List tab to see the terms you have added:

Step 2: Add the Taxonomy Vocabulary to your Content Type

You now need to associate this vocabulary to your content type. In this example we are going to be locking down the “Basic Page” content type, but you can follow the same steps for any content type.

Click on Structure > Content Types > Basic Page to view the Basic page configuration. Click on Manage Fields tab, then enter “Page Access” for the label under Add new field. Select “term reference” for the field type, and "Select list" for the widget.

Click Save on the bottom of the page, then on the Field settings page select the “Page Access” value:

Click Save field settings, and on the Basic page settings select the Required Field checkbox:

Click Save settings. You will be back on the Basic Page Manage fields tab. Drag the Page Access field you just created below the Title field to make it easier to find:

Click Save on the bottom of the page.

To make this field not display on the page, click on Manage Display and drag Page Access into the Hidden section:

Now, you can create a new Basic page by going to Content > Add content > Basic page and you will see the new Page Access field:

Step 3: Add Roles

Go to People > Permissions > Roles, and add a role for both beta and internal developers:

Step 4: Install and Enable Taxonomy Access Control Module

Add the Taxonomy Access Control module to the system by:

Private Cloud: downloading the module and unzipping the module to {devportal_root}/sites/all/modules/contrib. {devportal_root} is by default /var/www/html.

Apigee Cloud: Add the module to /sites/all/modules/contrib to your Git repo and push to your Git origin to deploy.

On a production system in private cloud, make sure to follow security guidelines for setting file permissions and ownership: https://www.drupal.org/node/244924

Enable Taxonomy Access Control module under Modules on the admin bar.

Rebuild permissions by going to: Reports -> Status report and clicking the "Rebuild Permissions" link under the Node Access Permissions row.

Step 5: Configure Taxonomy Access Control Module

You now have the taxonomy vocabulary configured for pages, and have roles to link to the taxonomy you created. The last step is to configure how the role matches the taxonomy vocabulary.

Go to Configuration > Taxonomy Access Control to configure the access control.

For details on on how to configure Taxonomy Access Control, check out:

Step 3 at: https://community.apigee.com/articles/15169/smartdocs-role-based-access-control.html

Resources

Taxonomy Access Control Documentation

Version history
Last update:
‎04-01-2015 03:57 PM
Updated by: