How to protect a directory of assets


I’m on CakePHP 2.x. I’m currently sending files from the response object to keep them safe behind authentication. I now have a situation where I’m going to have a whole directory of files that need to be safe behind authentication. These are HTML, js, CSS, images, audio files that are compiled by a different application that I need to put on our site. All of those assets need to be secured behind authentication though. I thought about parsing the html file and rebuilding it to make it more dynamic and to load the secure assets, but that’s a really big pain. Or is there a good lib that will already do that?

Any thoughts on the best way to achieve this?