suntrop Posted February 23, 2017 Share Posted February 23, 2017 I couldn't find much about the pagefileSecure option. Is this just a runtime setting I can switch on or off anytime? Or is it only for files uploaded later? Is there anything changing in the files/assets folder? Link to comment Share on other sites More sharing options...
Can Posted February 24, 2017 Share Posted February 24, 2017 as far as I know (never used it so far) it works on newly created files only (so after enabling pagefileSecure) and changes file urls, think by adding a hyphen or something which I guess .htaccess blocks already..have a look at wire/config.php excerpt: /** * Secure page files? * * When, true, prevents http access to file assets of access protected pages. * * Set to true if you want files on non-public or unpublished pages to be * protected from direct URL access. * * When used, such files will be delivered at a URL that is protected from public access. * * @var bool * */ $config->pagefileSecure = false; /** * Prefix for secure page files * * One or more characters prefixed to the pathname of secured file dirs. * * If use of this feature originated with a pre-2.3 install, this may need to be * specified as "." rather than "-". * */ $config->pagefileSecurePathPrefix = '-'; to get it working you need to block access by guest role for those templates, have a read at https://processwire.com/talk/topic/5292-proctecting-files-from-non-logged-in-users/ might be of interest:https://processwire.com/talk/topic/15622-pagefilesecure-and-pageispublic-hook-not-working/ 2 Link to comment Share on other sites More sharing options...
suntrop Posted February 24, 2017 Author Share Posted February 24, 2017 Thanks Can. I knew that already. I was wondering how it works. The brief description in the config is a little less to know about it. I need to go a step deeper I think, because the files I am going to protect are for specific users only (billing PDF) Link to comment Share on other sites More sharing options...
Wanze Posted February 24, 2017 Share Posted February 24, 2017 If you enable the pagefileSecure, requets to serve files from /site/assets/files are not delivered directly by the webserver but routed through ProcessWire, which does the permission checks. So it slows down the delivery of the files, because they are served by PHP. If you only need to secure specific files, you could also try the SecureFile module: http://modules.processwire.com/modules/fieldtype-secure-file/ It is an extension of a regular file field with the possibility to customize the storage location - here you would typically choose a folder outside the web root. Cheers 2 Link to comment Share on other sites More sharing options...
suntrop Posted February 26, 2017 Author Share Posted February 26, 2017 Thanks Wanze! I had a look at it, but I think I will develop something on my own. I am always in worries when using 3rd party plugins for a vital part of my website Especially if it is not "easily" exchangeable. Link to comment Share on other sites More sharing options...
Wanze Posted February 26, 2017 Share Posted February 26, 2017 @suntrop That decision is up to you of course. Since the module is released open source, you are free to change the code according to your needs - should you need any starting point ;-) 2 Link to comment Share on other sites More sharing options...
suntrop Posted February 26, 2017 Author Share Posted February 26, 2017 Yeah … maybe I'll give it a try. Had just a short look into the code, don't know if I understand everything And that could be the bottle neck, if I need to update it somewhen 1 Link to comment Share on other sites More sharing options...
tires Posted November 4, 2021 Share Posted November 4, 2021 Hey! I just added this line in my config.php $config->pagefileSecure = true; I've got two questions: Is there a way to change existing files to secure ones? Do i necessarily need the line: $config->pagefileSecurePathPrefix = '-'; Thanks and greets! 1 Link to comment Share on other sites More sharing options...
tires Posted November 8, 2021 Share Posted November 8, 2021 BTW. Is there a way to check if a file is secure or not? Or to check if there are insecure files on my website? Thanks! Link to comment Share on other sites More sharing options...
Kholja Posted November 10, 2021 Share Posted November 10, 2021 On 11/5/2021 at 12:41 AM, tires said: Is there a way to change existing files to secure ones? Do i necessarily need the line: $config->pagefileSecurePathPrefix = '-'; Thanks and greets! I've done a small test. Let's say you have a template "onlymembers" with a files-field "members_pdf". In this case your pdf file is safe as soon as you set pagefileSecure to true AND restrict the access of the template "onlymembers" (i.e. remove all guest access rights). ProcessWire gave me a 404 page. You don't need the pagefileSecurePathPrefix line. It is set by default. Hope that helps. 1 Link to comment Share on other sites More sharing options...
Kholja Posted November 10, 2021 Share Posted November 10, 2021 On 11/8/2021 at 1:17 PM, tires said: Is there a way to check if a file is secure or not? Or to check if there are insecure files on my website? Thanks! As of ProcessWire 3.0.166 this may be an option: https://processwire.com/api/ref/page/secure-files/ 1 Link to comment Share on other sites More sharing options...
tires Posted November 10, 2021 Share Posted November 10, 2021 Thanks a lot! That helps me! I recognized that the secure directories now looks like this "-myfolder". But if i echo the file-url the path is without the "-" i.e. "myfolder/myfile.pdf". Is that how it should work? And is there a solution for this problem: 1 hour ago, Kholja said: Is there a way to change existing files to secure ones? Thanks!!! Link to comment Share on other sites More sharing options...
tires Posted October 11, 2022 Share Posted October 11, 2022 After a few month walk by i just want to ask again: Is there a way to change existing files into secure files? If i understand this right after i add the $config->pagefileSecure = true to my config file all files from now on are secure ... but not the old ones, right? Link to comment Share on other sites More sharing options...
tires Posted October 17, 2022 Share Posted October 17, 2022 On 10/11/2022 at 10:37 PM, tires said: Is there a way to change existing files into secure files? If i understand this right after i add the $config->pagefileSecure = true to my config file all files from now on are secure ... but not the old ones, right? Ok, i find it out: If i add "$config->pagefileSecure = true;" to my site/config.php all files are secure immediately! I does't have to do any further steps to secure old files. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now