Line 9: | Line 9: | ||
Functions are definied in the following order: | Functions are definied in the following order: | ||
<pre>Function DefineAccessControlItem( _ role, resourceType, folder, _ folderView, folderCreate, folderRename, folderDelete, _ fileView, fileUpload, fileRename, fileDelete )</pre> | <pre>Function DefineAccessControlItem( _ role, resourceType, folder, _ folderView, folderCreate, folderRename, folderDelete, _ fileView, fileUpload, fileRename, fileDelete )</pre> | ||
− | |||
* '''role'''<br>The role is an attribute which sets the type of the user. It is set to "*" as default and you may treat as 'every user'. You may set this parameter to other name like: 'user' or 'limited_functions'. The name of the user type will be directly connected to the function the user may use. | * '''role'''<br>The role is an attribute which sets the type of the user. It is set to "*" as default and you may treat as 'every user'. You may set this parameter to other name like: 'user' or 'limited_functions'. The name of the user type will be directly connected to the function the user may use. | ||
Line 19: | Line 18: | ||
* '''other information'''<br> Many "AccessControl" entries can be added. All attributes are optional. | * '''other information'''<br> Many "AccessControl" entries can be added. All attributes are optional. | ||
+ | |||
Subfolders inherit their default settings from their parents' definitions. | Subfolders inherit their default settings from their parents' definitions. | ||
− | + | ==== Example 1 ==== | |
+ | |||
+ | If you want to restrict the upload, rename or delete of files in the "Logos" folder of the resource type "Images": | ||
<pre>Set accessControl(1) = DefineAccessControlItem("*", "Images", "/Logos", true, true, true, true, true, false, false, false)</pre> | <pre>Set accessControl(1) = DefineAccessControlItem("*", "Images", "/Logos", true, true, true, true, true, false, false, false)</pre> | ||
− | The above example only refers to file operations in the folder "/Logos" itself. It doesn't restrict operations on the folder so the user can delete or rename the folder. In order to limit users ability to modify the folder (not its context) you should change permissions in the parent folder. | + | The above example only refers to file operations in the folder "/Logos" itself. It doesn't restrict operations on the folder so the user can delete or rename the folder. In order to limit users ability to modify the folder (not its context) you should change permissions in the parent folder. |
+ | |||
+ | ==== Example 2 ==== | ||
<pre>Set accessControl(1) = DefineAccessControlItem("*", "Images", "/", true, true, false, false, true, false, false, false)</pre> | <pre>Set accessControl(1) = DefineAccessControlItem("*", "Images", "/", true, true, false, false, true, false, false, false)</pre> | ||
− | Now a user can view and create a folder, but he will be unable to rename or delete it. | + | Now a user can view and create a folder, but he will be unable to rename or delete it. |
+ | |||
+ | '''Note''':Please, remember to adjust Dim accessControl(0) to Dim accessControl(1) as necessary.<br> | ||
− | === | + | === Sessions === |
In order to enable the access control options for different users you should initialize a session. | In order to enable the access control options for different users you should initialize a session. | ||
<pre>CKFinder_Config.Add "RoleSessionVar", "CKFinder_UserRole" | <pre>CKFinder_Config.Add "RoleSessionVar", "CKFinder_UserRole" | ||
</pre> | </pre> | ||
− | + | ==== Example 3 ==== | |
− | First role ''' | + | In your config.php file you can create three different roles:<br> First role, '''every user''' (wildcard "*" is used): |
− | <pre>Set accessControl(1) = DefineAccessControlItem("*", "*", "/", | + | <pre>Set accessControl(1) = DefineAccessControlItem("*", "*", "/", true, false, false, false, true, false, false, false) |
</pre> | </pre> | ||
− | Second role '''user''': | + | Second role '''registered user''': |
− | <pre>Set accessControl(2) = DefineAccessControlItem(" | + | <pre>Set accessControl(2) = DefineAccessControlItem("registered", "*", "/", true, true, false, false, true, true, false, false) |
</pre> | </pre> | ||
− | Third role ''' | + | Third role '''admin''': |
− | <pre>Set accessControl(3) = DefineAccessControlItem(" | + | <pre>Set accessControl(3) = DefineAccessControlItem("admin", "*", "/", true, true, true, true, true, true, true, true) |
</pre> | </pre> | ||
− | You've created three different users permissions. | + | You've created three different users permissions. The default user (everybody) is allowed to browse all files and folders. Registered user has also the ability to upload files and create folders. The administrator has full permissions. |
− | ''' | + | '''<br>''' |
− | Now you | + | Now let's say you have an authentication mechanism somewhere in your web application. In this file you initialize the session with session_start(); command and assign one of the pre-defined roles to the user: |
+ | <pre><% | ||
+ | Session("CKFinder_UserRole")="admin" | ||
+ | %></pre> | ||
+ | if you want to use the admin role. | ||
+ | <pre><% | ||
+ | Session("CKFinder_UserRole")="registered" | ||
+ | %></pre> | ||
+ | if you want to use the role assigned to registered users. | ||
+ | <pre><% | ||
+ | Session("CKFinder_UserRole")="guest" | ||
+ | %></pre> | ||
+ | ''guest'' doesn't have assigned any specific permissions, so the default values are used (defined with "*") | ||
<pre><% | <pre><% | ||
− | Session("CKFinder_UserRole")=" | + | Session("CKFinder_UserRole")="any_other_value" |
− | %></pre> | + | %></pre> |
+ | same situation, default values are used. |
Revision as of 12:39, 11 January 2008
Access control is a way you to give your users different permissions while working on folders and files. The default setting in the config.asp file gives permission to every user and permits all the options. In order to change this configuration you must firstly know the basic of the accessControl(0) function placed in the config.asp file.
The syntax of the ACL Items
The syntax of the ACL entries is as followed:
Set accessControl(0) = DefineAccessControlItem("*", "*", "/", true, true, true, true, true, true, true, true)
Functions are definied in the following order:
Function DefineAccessControlItem( _ role, resourceType, folder, _ folderView, folderCreate, folderRename, folderDelete, _ fileView, fileUpload, fileRename, fileDelete )
- role
The role is an attribute which sets the type of the user. It is set to "*" as default and you may treat as 'every user'. You may set this parameter to other name like: 'user' or 'limited_functions'. The name of the user type will be directly connected to the function the user may use.
- resourceType
The resourceType defines the resources handled in CKFinder. A resource type is nothing more than a way to group files under different paths, each one having different configuration settings. e.g. Images, Flash, Files.It is set to "*" as default and means that all of the resources are available.
- folder
Folder determines where your limitations will be used. By placing the folders name you specify the place you want to put your restrictions in. It is set to "/" as default so no folder is set.
- folder and file options
The rest of the variables are bool type and can be set as true or false. True of course enables an option, false disables it.
- other information
Many "AccessControl" entries can be added. All attributes are optional.
Subfolders inherit their default settings from their parents' definitions.
Example 1
If you want to restrict the upload, rename or delete of files in the "Logos" folder of the resource type "Images":
Set accessControl(1) = DefineAccessControlItem("*", "Images", "/Logos", true, true, true, true, true, false, false, false)
The above example only refers to file operations in the folder "/Logos" itself. It doesn't restrict operations on the folder so the user can delete or rename the folder. In order to limit users ability to modify the folder (not its context) you should change permissions in the parent folder.
Example 2
Set accessControl(1) = DefineAccessControlItem("*", "Images", "/", true, true, false, false, true, false, false, false)
Now a user can view and create a folder, but he will be unable to rename or delete it.
Note:Please, remember to adjust Dim accessControl(0) to Dim accessControl(1) as necessary.
Sessions
In order to enable the access control options for different users you should initialize a session.
CKFinder_Config.Add "RoleSessionVar", "CKFinder_UserRole"
Example 3
In your config.php file you can create three different roles:
First role, every user (wildcard "*" is used):
Set accessControl(1) = DefineAccessControlItem("*", "*", "/", true, false, false, false, true, false, false, false)
Second role registered user:
Set accessControl(2) = DefineAccessControlItem("registered", "*", "/", true, true, false, false, true, true, false, false)
Third role admin:
Set accessControl(3) = DefineAccessControlItem("admin", "*", "/", true, true, true, true, true, true, true, true)
You've created three different users permissions. The default user (everybody) is allowed to browse all files and folders. Registered user has also the ability to upload files and create folders. The administrator has full permissions.
Now let's say you have an authentication mechanism somewhere in your web application. In this file you initialize the session with session_start(); command and assign one of the pre-defined roles to the user:
<% Session("CKFinder_UserRole")="admin" %>
if you want to use the admin role.
<% Session("CKFinder_UserRole")="registered" %>
if you want to use the role assigned to registered users.
<% Session("CKFinder_UserRole")="guest" %>
guest doesn't have assigned any specific permissions, so the default values are used (defined with "*")
<% Session("CKFinder_UserRole")="any_other_value" %>
same situation, default values are used.