Hi guys,
I am evaluating CKFinder in an ASP.NET 3.5 application. I would like to know if there is a way to configure Access Control for a specific folder inside a resource.
In my solution I have a files folder, which is the base directory for CKFinder, containing a single resource documents pointing to files/documents/ folder.
The code is as follows:-
The above thing works, and users can create, upload, delete files and folders in Documents resource.
Now what I would like to do is, restrict the user only to upload, rename or delete files and folders in the "/Documents/Reports" folder of the resource "Documents".
So I updated my code as follows as described in the documentation. But for some reason no file or folders are appearing inside the control.
I have also tried setting acl.Folder = "/Reports/";, but it sill doesn't seem to be working.
Any idea how can I achieve this?
Awaiting
Nabeel
I am evaluating CKFinder in an ASP.NET 3.5 application. I would like to know if there is a way to configure Access Control for a specific folder inside a resource.
In my solution I have a files folder, which is the base directory for CKFinder, containing a single resource documents pointing to files/documents/ folder.
The code is as follows:-
/** * All configuration settings must be defined here. */ public override void SetConfig() { // Paste your license name and key here. If left blank, CKFinder will // be fully functional, in Demo Mode. LicenseName = ""; LicenseKey = ""; // The base URL used to reach files in CKFinder through the browser. BaseUrl = "~/files/"; // The phisical directory in the server where the file will end up. If // blank, CKFinder attempts to resolve BaseUrl. BaseDir = ""; // Thumbnail settings. // "Url" is used to reach the thumbnails with the browser, while "Dir" // points to the physical location of the thumbnail files in the server. Thumbnails.Url = BaseUrl + "_thumbs/"; Thumbnails.Dir = BaseDir + "_thumbs/"; Thumbnails.Enabled = true; Thumbnails.DirectAccess = false; Thumbnails.MaxWidth = 100; Thumbnails.MaxHeight = 100; Thumbnails.Quality = 80; // Set the maximum size of uploaded images. If an uploaded image is // larger, it gets scaled down proportionally. Set to 0 to disable this // feature. Images.MaxWidth = 1600; Images.MaxHeight = 1200; Images.Quality = 80; // Indicates that the file size (MaxSize) for images must be checked only // after scaling them. Otherwise, it is checked right after uploading. CheckSizeAfterScaling = true; // Due to security issues with Apache modules, it is recommended to leave the // following setting enabled. It can be safely disabled on IIS. ForceSingleExtension = true; // For security, HTML is allowed in the first Kb of data for files having the // following extensions only. HtmlExtensions = new string[] { "html", "htm", "xml", "js" }; // Folders to not display in CKFinder, no matter their location. No // paths are accepted, only the folder name. // The * and ? wildcards are accepted. HideFolders = new string[] { ".svn", "CVS" }; // Files to not display in CKFinder, no matter their location. No // paths are accepted, only the file name, including extension. // The * and ? wildcards are accepted. HideFiles = new string[] { ".*" }; // Perform additional checks for image files. SecureImageUploads = true; // The session variable name that CKFinder must use to retrieve the // "role" of the current user. The "role" is optional and can be used // in the "AccessControl" settings (bellow in this file). RoleSessionVar = "CKFinder_UserRole"; // ACL (Access Control) settings. Used to restrict access or features // to specific folders. // Several "AccessControl.Add()" calls can be made, which return a // single ACL setting object to be configured. All properties settings // are optional in that object. // Subfolders inherit their default settings from their parents' definitions. // // - The "Role" property accepts the special "*" value, which means // "everybody". // - The "ResourceType" attribute accepts the special value "*", which // means "all resource types". AccessControl acl = AccessControl.Add(); acl.Role = "*"; acl.ResourceType = "Documents "; acl.Folder = "/"; acl.FolderView = true; acl.FolderCreate = true; acl.FolderRename = true; acl.FolderDelete = true; acl.FileView = true; acl.FileUpload = true; acl.FileRename = true; acl.FileDelete = true; // Resource Type settings. // A resource type is nothing more than a way to group files under // different paths, each one having different configuration settings. // Each resource type name must be unique. // When loading CKFinder, the "type" querystring parameter can be used // to display a specific type only. If "type" is omitted in the URL, // the "DefaultResourceTypes" settings is used (may contain the // resource type names separated by a comma). If left empty, all types // are loaded. DefaultResourceTypes = ""; ResourceType type; type = ResourceType.Add( "Documents" ); type.Url = BaseUrl + "documents/"; type.Dir = BaseDir == "" ? "" : BaseDir + "documents/"; type.MaxSize = 0; type.AllowedExtensions = new string[] { "7z", "aiff", "asf", "avi", "bmp", "csv", "doc", "fla", "flv", "gif", "gz", "gzip", "jpeg", "jpg", "mid", "mov", "mp3", "mp4", "mpc", "mpeg", "mpg", "ods", "odt", "pdf", "png", "ppt", "pxd", "qt", "ram", "rar", "rm", "rmi", "rmvb", "rtf", "sdc", "sitd", "swf", "sxc", "sxw", "tar", "tgz", "tif", "tiff", "txt", "vsd", "wav", "wma", "wmv", "xls", "zip" }; type.DeniedExtensions = new string[] { }; }
The above thing works, and users can create, upload, delete files and folders in Documents resource.
Now what I would like to do is, restrict the user only to upload, rename or delete files and folders in the "/Documents/Reports" folder of the resource "Documents".
So I updated my code as follows as described in the documentation. But for some reason no file or folders are appearing inside the control.
AccessControl acl = AccessControl.Add(); acl.Role = "*"; acl.ResourceType = "Documents"; acl.Folder = "/Documents/Reports/"; acl.FolderView = true; acl.FolderCreate = true; acl.FolderRename = true; acl.FolderDelete = true; acl.FileView = true; acl.FileUpload = true; acl.FileRename = true; acl.FileDelete = true;
I have also tried setting acl.Folder = "/Reports/";, but it sill doesn't seem to be working.
Any idea how can I achieve this?
Awaiting
Nabeel
Re: Access Control configuration for a folder within a resou
The users now have access only to the Reports folder.
However with the above settings, the users can still see the rest of the folder hierarchy in the resource. They can't access other folders in the resource, but they can see their names and subfolders.
Is their a way to completely hide the rest of the folders, so that users don't even know they exist and only see Reports folder?
Awaiting
Nabeel