Search code examples
javascriptjavackfinder

Private folders in CKFinder


I'm running CKFinder/CKEditor through Apache Tomcat, using Java and JavaScript. There are several projects, and the problem is that I can't stop people on one project from accessing images stored for a different project. I'd like to simply be able to change the BaseURL dynamically, but I can't seem to do that. Is there any way to give each user their own folder that they, and only they can access?


Solution

  • There are at least ways to modify dynamically paths in CKFinder 2 for Java.

    Using id assigned to a CKFinder instance

    If you assign an id to CKFinder instance, this id will be passed to the server connector on each request. You may use it as a token and translate each unique id into the proper server path on the server side. Make sure to use a long/complex hash so that users could not access path where they should not have access by manipulating the id easily.

    The advantage of this approach is that you may assign for each instance of CKFinder a different baseUrl/baseDir, for example to have separate folders for images per article etc.

    Session variables

    Another option is to use session variables. Once the user logs in, store in a session variable proper baseDir/baseUrl variables.

    Setting CKFinder configuration outside config.xml

    In order to use id or sessions, you need to be able to tell CKFinder to use them. For more details on how to modify CKFinder configuration dynamically in your own class check the documentation: http://docs.cksource.com/CKFinder_2.x/Developers_Guide/Java/Configuration/Extending