How to protect content behind a login?

Author Message

Luis Cruz

Tuesday 29 March 2005 8:47:23 am

Greetings all; this seems to be a common question as I have searched the forums and documentation for an answer. However, I have yet to come across a posting or document that clearly explains how the user/role system works and how to use it to protect content.

Can anyone provide a detailed, step-by-step process how one can place content into the CMS and ensure that a user must be logged in/authenticated by the ezPublish system before they can access it? Or at the very least, help me draw one up in this thread?

I am currently using 3.4.X, so instructions targeted to that platform are of primary interest to me. However, if 3.5.X makes the process more clear and straightforward, please include instructions for that as well. Would give me leverage to get us to upgrade sooner. :)

Thanks in advance.

Mark Marsiglio

Tuesday 29 March 2005 9:09:55 am

You can find more details about each step within the documentation, but the basics are:

It is rougly the same for 3.4 and 3.5

1) Create a new "section" using the setup tab
2) Create a new user group in the users tab
3) Create a new role in the users tab, and allow access to the content module (limited), and limit to the new section that you have created.
4) Add the users who you want to have access to the protected content to this new user group
5) Assign the new section to the content you want to have protected.
6) Clear the caches

Once a user logs in, they will see the protected items in the navigation. If they try to link directly to a protected page, they will be presented with an Access Denied screen, on which they can log in.

As long as the anonymous user role is not given access to this new section, they should not be able to see anything in it.

Good luck...
Mark

http://www.thinkcreative.com
Turning Ideas Into Strategic Solutions

Luis Cruz

Tuesday 29 March 2005 12:04:53 pm

In theory, those directions make sense; however, I am still having problems with them in practice. Here are the exact steps I took and the result; perhaps one can help me refine the results to meet my needs.

1. Created a new folder called "partnercontent" in Media -> Files

2. Added a File object to that folder.

3. Created a new section (called "Partner Content" and assigned the section to the "partnercontent" folder.

4. Created a new role called "Partner" and gave it content read access to any class in the "Partner Content" section.

5. Created a new user called "Partner User" and placed it under the "Partner" role.

Now, when I hit the URL for the file object as an anonymous user on the web site (not the CMS side), my homepage comes up, and the debug information at the bottom of the page is this:

Timing:  	Mar 29 2005 14:51:34

Module start 'content'

Warning: Insufficient permissions 	Mar 29 2005 14:51:34

Function required:
 Module : content
 Function : read
 ClassID : 12
 MainNodeID : 1173
Policies that didn't match:
 PolicyID : p_398
  Limitation : Section
  Required : 1, 10, 11, 12, 13, 14, 15, 16, 3, 5, 6, 7, 8, 9, 
 PolicyID : p_400
  Limitation : Class
  Required : 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 

Timing: 	Mar 29 2005 14:51:34

Module end 'error'

Timing: 	Mar 29 2005 14:51:34

End

Now, if I understand the original reply, this is somewhat expected behavior. Rather than seeing an "access denied" page, the anonymous user is being bounced to my homepage.

So, the question then becomes, how do I close the loop and have an anonymous user redirected to a login page rather than my homepage or an "access denied" page?

Thanks for the assistance so far!

Mark Marsiglio

Tuesday 29 March 2005 10:45:16 pm

If you are logged in as a partner user, do you get the page correctly? I am not sure if having the files located in the media area instead of in the content tree matters or not, but I have not tried that before. You may want to experiment with moving the files into a folder in the main content area as a test.

Also, check the error.ini settings, as it contains some settings that control what page a user is redirected to if they get an access denied error.

http://www.thinkcreative.com
Turning Ideas Into Strategic Solutions

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 20:58:56
Script start
Timing: Jan 18 2025 20:58:56
Module start 'layout'
Timing: Jan 18 2025 20:58:56
Module start 'content'
Timing: Jan 18 2025 20:58:57
Module end 'content'
Timing: Jan 18 2025 20:58:57
Script end

Main resources:

Total runtime0.6599 sec
Peak memory usage4,096.0000 KB
Database Queries60

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0102 588.0313152.6406
Module start 'layout' 0.01030.0023 740.671939.4766
Module start 'content' 0.01260.6458 780.1484554.1250
Module end 'content' 0.65830.0016 1,334.273416.1406
Script end 0.6599  1,350.4141 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.4950160.0002
Check MTime0.00140.2113160.0001
Mysql Total
Database connection0.00100.147810.0010
Mysqli_queries0.600290.9448600.0100
Looping result0.00060.0960580.0000
Template Total0.629695.420.3148
Template load0.00200.296720.0010
Template processing0.627695.096420.3138
Template load and register function0.00030.045810.0003
states
state_id_array0.00070.105610.0007
state_identifier_array0.00060.095820.0003
Override
Cache load0.00170.2583370.0000
Sytem overhead
Fetch class attribute can translate value0.00060.083820.0003
Fetch class attribute name0.00160.249050.0003
XML
Image XML parsing0.00100.144120.0005
class_abstraction
Instantiating content class attribute0.00000.002260.0000
General
dbfile0.00070.1125150.0000
String conversion0.00000.001340.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
7content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 18
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs