Line 1: | Line 1: | ||
__TOC__ | __TOC__ | ||
− | Access control is a way you to give your users different permissions while working on folders and files. The default setting in the config.php 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 '''$config['AccessControl']''' | + | Access control is a way you to give your users different permissions while working on folders and files. The default setting in the config.php 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 '''$config['AccessControl']''' settings placed in the config.php file. |
− | The syntax of the | + | <br> |
+ | |||
+ | The syntax of the ACL entries is as followed: | ||
<pre>$config['AccessControl'][] = Array( | <pre>$config['AccessControl'][] = Array( | ||
'role' => '*', | 'role' => '*', | ||
Line 17: | Line 19: | ||
'fileRename' => true, | 'fileRename' => true, | ||
'fileDelete' => true);</pre> | 'fileDelete' => true);</pre> | ||
− | The | + | * '''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 'everybody'. 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.<br> |
− | |||
− | |||
− | + | * '''resourceType'''<br>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''' '''<br>'''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''' <br>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''' <br>Many "AccessControl" entries can be added. All attributes are optional.<br>Subfolders inherit their default settings from their parents' definitions. | |
− | + | <br> | |
− | === | + | ==== Example 1: ==== |
− | + | If you want to restrict the upload, rename or delete of files in the "Logos" folder of the resource type "Images": | |
<pre>$config['AccessControl'][] = Array( | <pre>$config['AccessControl'][] = Array( | ||
'role' => '*', | 'role' => '*', | ||
Line 41: | Line 41: | ||
'fileRename' => false, | 'fileRename' => false, | ||
'fileDelete' => false);</pre> | 'fileDelete' => 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>$config['AccessControl'][] = Array( | <pre>$config['AccessControl'][] = Array( | ||
'role' => '*', | 'role' => '*', | ||
Line 52: | Line 54: | ||
Now a user can view and create a folder, but he will be unable to rename or delete it. <br> | Now a user can view and create a folder, but he will be unable to rename or delete it. <br> | ||
− | === | + | === Sessions === |
In order to enable the access control options for different users you should initialize the session data by uncommenting the "session_start()" call: | In order to enable the access control options for different users you should initialize the session data by uncommenting the "session_start()" call: | ||
− | <pre>$config['RoleSessionVar'] = 'CKFinder_UserRole' | + | <pre>session_start();</pre> |
− | + | The roleSessionVar is a session variable name that CKFinder must use to retrieve the "role" of the current user. | |
− | + | <pre>$config['RoleSessionVar'] = 'CKFinder_UserRole';</pre> | |
− | + | To switch between different user roles, simply change the session variable: | |
− | ==== Example: ==== | + | <pre>$_SESSION['CKFinder_UserRole'] = "admin"; |
+ | </pre> | ||
+ | ==== Example 3: ==== | ||
In your config.php file you can create three different roles: | In your config.php file you can create three different roles: | ||
Line 110: | Line 114: | ||
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:<br> | 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:<br> | ||
− | <pre>$_SESSION['CKFinder_UserRole'] ='admin';</pre> | + | <pre>$_SESSION['CKFinder_UserRole'] ='admin';</pre> |
if you want to use the admin role. | if you want to use the admin role. | ||
− | <pre>$_SESSION['CKFinder_UserRole'] ='registered';</pre> | + | <pre>$_SESSION['CKFinder_UserRole'] ='registered';</pre> |
if you want to use the role assigned to registered users. | if you want to use the role assigned to registered users. | ||
− | <pre>$_SESSION['CKFinder_UserRole'] = 'guest';</pre> | + | <pre>$_SESSION['CKFinder_UserRole'] = 'guest';</pre> |
''guest'' doesn't have assigned any specific permissions, so the default values are used (defined with "*") | ''guest'' doesn't have assigned any specific permissions, so the default values are used (defined with "*") | ||
− | <pre>$_SESSION['CKFinder_UserRole'] = 'any_other_value';</pre> | + | <pre>$_SESSION['CKFinder_UserRole'] = 'any_other_value';</pre> |
same situation, default values are used. | same situation, default values are used. |
Revision as of 10:17, 11 January 2008
Contents
Access control is a way you to give your users different permissions while working on folders and files. The default setting in the config.php 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 $config['AccessControl'] settings placed in the config.php file.
The syntax of the ACL entries is as followed:
$config['AccessControl'][] = Array( 'role' => '*', 'resourceType' => '*', 'folder' => '/', 'folderView' => true, 'folderCreate' => true, 'folderRename' => true, 'folderDelete' => true, 'fileView' => true, 'fileUpload' => true, 'fileRename' => true, 'fileDelete' => true);
- role
The role is an attribute which sets the type of the user. It is set to "*" as default and you may treat as 'everybody'. 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":
$config['AccessControl'][] = Array( 'role' => '*', 'resourceType' => 'Images', 'folder' => '/Logos', 'fileUpload' => false, 'fileRename' => false, 'fileDelete' => 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:
$config['AccessControl'][] = Array( 'role' => '*', 'resourceType' => 'Images', 'folder' => '/', 'folderView' => true, 'folderCreate' => true, 'folderRename' => false, 'folderDelete' => false);
Now a user can view and create a folder, but he will be unable to rename or delete it.
Sessions
In order to enable the access control options for different users you should initialize the session data by uncommenting the "session_start()" call:
session_start();
The roleSessionVar is a session variable name that CKFinder must use to retrieve the "role" of the current user.
$config['RoleSessionVar'] = 'CKFinder_UserRole';
To switch between different user roles, simply change the session variable:
$_SESSION['CKFinder_UserRole'] = "admin";
Example 3:
In your config.php file you can create three different roles:
First role, every user (wildcard "*" is used):
$config['AccessControl'][] = Array( 'role' => '*', 'resourceType' => '*', 'folder' => '/', 'folderView' => true, 'folderCreate' => false, 'folderRename' => false, 'folderDelete' => false, 'fileView' => true, 'fileUpload' => false, 'fileRename' => false, 'fileDelete' => false);
Second role, registered user:
$config['AccessControl'][] = Array( 'role' => 'registered', 'resourceType' => '*', 'folder' => '/', 'folderView' => true, 'folderCreate' => true, 'folderRename' => false, 'folderDelete' => false, 'fileView' => true, 'fileUpload' => true, 'fileRename' => false, 'fileDelete' => false);
Third role, admin:
$config['AccessControl'][] = Array( 'role' => 'admin', 'resourceType' => '*', 'folder' => '/', 'folderView' => true, 'folderCreate' => true, 'folderRename' => true, 'folderDelete' => true, 'fileView' => true, 'fileUpload' => true, 'fileRename' => true, 'fileDelete' => true);
You've created three different users permissions. The default user (guest) 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.