How to create a restricted area on your homepage

From OpenCms Wiki
(Difference between revisions)
Jump to: navigation, search
m (Tune guest access)
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
'''Since no one seems to edit this I'm pasting something I found in the opencms mailing list and the forums...'''
+
How to create members-only areas or protected files/folders by requiring a valid username and password.
  
There are pages which should be accessible for members only, which means that the visitor of the website who wants to see the page has to login first with username and password.
+
If your site contains resources that should not be open to the general public, you can use OpenCms' Permissions mechanism to add password-protection on the specific resources. This way, visitors will not be granted access unless they can provide a valid username and password.
  
I've read in Matt Butcher's book that there are webusers for such problems. So I created a webuser "Partner" in my new group "webuser-group" which has no parents.
+
You can use this to protect single files, or you can create members-only ''areas'', by tuning permissions on the parent folder(s).
  
After that I changed the permissions for the restricted file:
+
'''NOTE: The steps described here are for a single user, but should work just as well for a group.'''
Guests: -r -w -c -d -v
+
webuser-group: +r -w -c -d +v
+
  
NOTE: you should '''uncheck the permisions for the Guests''' group, DON'T check the denied column because this has greater priority, just keep
 
  
 +
== Create your user / group ==
 +
Create a web/guest user (we'll call it "myuser" here).
  
Here's how ACLs in OpenCms 6 work in general:
+
Typically, this user should be created either in the existing Guests group, or a dedicated custom group (we'll call it "mygroup"). Give your new user the role "No role" if it should not have access to the OpenCms workplace.
 +
 
 +
== Tune guest access ==
 +
On the resource you want to protect, open the "Permissions" dialog from the context menu.
 +
 
 +
On the guests group (Guests) settings: '''check "Overwrite inherited" and uncheck all permissions'''. Then click the "Set" button.
 +
 
 +
''Unchecked means "Unset", which is like a "weak deny". Unlike "deny", it can be overridden by an "allow".''
 +
 
 +
<pre>
 +
Guests: ?r ?w ?c ?d ?v (all unset)
 +
</pre>
 +
 
 +
The affected resource(s) should now be inaccessible to the public; Anyone requesting an affected resource will be prompted for a username and password.
 +
 
 +
== Tune user/group access ==
 +
Grant read/view access to the newly created user:
 +
 
 +
<pre>
 +
myuser: +r -w -c -d +v
 +
</pre>
 +
 
 +
... OR, if you're using a dedicated group, you can set the same permissions for the group instead:
 +
 
 +
<pre>
 +
mygroup: +r -w -c -d +v
 +
</pre>
 +
 
 +
'''That's it.''' For more info, see the [http://documentation.opencms.org/opencms-documentation/background/permissions-in-opencms/ documentation of OpenCms permissions].
 +
 
 +
 
 +
== How ACLs in OpenCms 6 work, in general ==
 +
 
 +
(This is by Alexander Kandzior, from the mailing list.)
  
 
Important: Forget about the group "inheritance" feature. Just make sure all
 
Important: Forget about the group "inheritance" feature. Just make sure all
 
groups you create are NOT in parent / child relationship with any other
 
groups you create are NOT in parent / child relationship with any other
goup.
+
group.
 +
 
 +
Let's say you have folder "/folderA/".
 +
 
 +
Let's also say you have a group "GroupB" and a group "GroupC".
  
Let's say you have folder "/folderA/"
 
Let's also say you have a group "GroupB" and a group "GroupC"
 
 
Members of these groups are also in group "Users" since they must be using
 
Members of these groups are also in group "Users" since they must be using
 
the workplace.
 
the workplace.
  
Let's say you want "/folderA/" accessible only for "GroupB", NOT for
+
Let's say you want "/folderA/" accessible only for "GroupB", NOT for "GroupC".
"GroupC".
+
  
 
Do it like this:
 
Do it like this:
  
Open the "Permissions" dialog on the context menu.
+
Open the "Permissions" dialog on the context menu:
1. Add the "Users" group from the list of groups. Leave all boxes unchecked
+
EXCEPT "overwrite inherited". This must be checked. Press "Set". You have
+
now removed all permissions of the "Users" group on the folder. To verify
+
this, check the permissions of any file in the folder using the permission
+
dialog. It should show NO permissions "()" for the users group.
+
 
+
2. Not add "GroupB" on the permission screen of "/folderA/". Give "GroupB"
+
the permissions you require, e.g. "read" and "write". Click set.
+
 
+
Now users of "GroupC" should not be able to view the "/folderA/" anymore in
+
the workplace, they have no read access to it etc.
+
  
Best Regards,
+
# Add the "Users" group from the list of groups. Leave all boxes unchecked EXCEPT "overwrite inherited". This must be checked. Press "Set". You have now removed all permissions of the "Users" group on the folder. To verify this, check the permissions of any file in the folder using the permission dialog. It should show NO permissions "()" for the users group.
Alex.
+
# Now add "GroupB" on the permission screen of "/folderA/". Give "GroupB" the permissions you require, e.g. "read" and "write". Click set.
  
Alexander Kandzior
+
Now users of "GroupC" should not be able to view the "/folderA/" anymore in the workplace, they have no read access to it etc.
Alkacon Software - The OpenCms Experts
+
http://www.alkacon.com
+
  
  
 
[[Category:Using / Maintaining an installation of OpenCms]]
 
[[Category:Using / Maintaining an installation of OpenCms]]

Latest revision as of 14:43, 3 September 2015

How to create members-only areas or protected files/folders by requiring a valid username and password.

If your site contains resources that should not be open to the general public, you can use OpenCms' Permissions mechanism to add password-protection on the specific resources. This way, visitors will not be granted access unless they can provide a valid username and password.

You can use this to protect single files, or you can create members-only areas, by tuning permissions on the parent folder(s).

NOTE: The steps described here are for a single user, but should work just as well for a group.


Contents

Create your user / group

Create a web/guest user (we'll call it "myuser" here).

Typically, this user should be created either in the existing Guests group, or a dedicated custom group (we'll call it "mygroup"). Give your new user the role "No role" if it should not have access to the OpenCms workplace.

Tune guest access

On the resource you want to protect, open the "Permissions" dialog from the context menu.

On the guests group (Guests) settings: check "Overwrite inherited" and uncheck all permissions. Then click the "Set" button.

Unchecked means "Unset", which is like a "weak deny". Unlike "deny", it can be overridden by an "allow".

Guests: ?r ?w ?c ?d ?v (all unset)

The affected resource(s) should now be inaccessible to the public; Anyone requesting an affected resource will be prompted for a username and password.

Tune user/group access

Grant read/view access to the newly created user:

myuser: +r -w -c -d +v

... OR, if you're using a dedicated group, you can set the same permissions for the group instead:

mygroup: +r -w -c -d +v

That's it. For more info, see the documentation of OpenCms permissions.


How ACLs in OpenCms 6 work, in general

(This is by Alexander Kandzior, from the mailing list.)

Important: Forget about the group "inheritance" feature. Just make sure all groups you create are NOT in parent / child relationship with any other group.

Let's say you have folder "/folderA/".

Let's also say you have a group "GroupB" and a group "GroupC".

Members of these groups are also in group "Users" since they must be using the workplace.

Let's say you want "/folderA/" accessible only for "GroupB", NOT for "GroupC".

Do it like this:

Open the "Permissions" dialog on the context menu:

  1. Add the "Users" group from the list of groups. Leave all boxes unchecked EXCEPT "overwrite inherited". This must be checked. Press "Set". You have now removed all permissions of the "Users" group on the folder. To verify this, check the permissions of any file in the folder using the permission dialog. It should show NO permissions "()" for the users group.
  2. Now add "GroupB" on the permission screen of "/folderA/". Give "GroupB" the permissions you require, e.g. "read" and "write". Click set.

Now users of "GroupC" should not be able to view the "/folderA/" anymore in the workplace, they have no read access to it etc.

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox