Authenticating Access to Large Amount of Static Data

Authenticating Access to Large Amount of Static Data

by Warren Toomey -
Number of replies: 2

Hi all & firstly thanks for Moodle!

I'm running Moodle 2.6 under Apache with a PostgreSQL database. I have a large body of hyperlinked documents that I want to make available through a single hyperlink, but only to authenticated Moodle users.Is there a way to set up a .htaccess file that will authenticate the MoodleSession cookie against the mdl_sessions table in the database, and if so, can someone point me at the way to do this? I've done basic .htaccess authentication before but nothing to this level?

Or is there a better or more sensible way to ensure only authenticated Moodle users get through to the static content hosted elsewhere on my Apache site?

Thanks, Warren

 

Average of ratings: -
In reply to Warren Toomey

Re: Authenticating Access to Large Amount of Static Data

by Matt Bury -
Picture of Plugin developers

Hi Warren,

Perhaps the Moodle File System option might meet your needs? http://docs.moodle.org/23/en/File_system_repository_FAQ

You need to activate it in the Moodle administration > Plugins > Repositories > Manage repositories and create the initial repository directory. You can then upload files to /moodledata/repository/ using your favourite FTP client and you'll be able to access them via Moodle's file manager.

It's worth noting that Moodle's file manager copies files from File System to the main repository when you create instances/links to them within Moodle. If you want to establish a central library of documents/resources then this is unlikely to be suitable, i.e. if you edit/change the files in /moodledata/repository/ the copies of them in Moodle's main repository (used in courses) will remain unchanged.

You can also directly access the files via a custom proxy script I wrote for a couple of my modules: https://github.com/matbury/SWF-Activity-Module2.5/blob/master/swf/content.php Please feel free to use and adapt it in any way you like. That's the beauty of open source smile

I hope this helps!

In reply to Matt Bury

Re: Authenticating Access to Large Amount of Static Data

by Warren Toomey -

Matt, thanks for the reply. I'm trying the file system repository but I must have done something wrong as the relative hyperlinks within the files I've uploaded are not working. Here's what I did.

I enabled the filesystem repository, which made the directory /usr/local/moodledata/respositories.

 I made a directory called test5 within respositories, and uploaded a pile of files there using rsync. I checked all the Linux file permissions were sensible for access by the www-data group.

Back in moodle, I gave test5 a repository name Test5. I set "all files in the repository to be accessible using relative links" true.

In my course, I added a label. In the label I added some text. I highlighted the text and added a hyperlink. I clicked on the file browser icon next to the URL field.

The file picker comes up, I chose Test5 and selected index.html from inside the Test5 repository. When selecting the file, I chose "Create an alias/shortcut to the file" instead of "Make a copy of the file".

After inserting the link and saving the tag, I try the hyperlink which works and I see the file's contents with the URL: http://website/pluginfile.php/168/mod_label/intro/index.html

However, clicking on any relative hyperlink in that file gives: Sorry, the requested file could not be found.

So, something I'm doing is not allowing the correct moodle URL to be saved in the hyperlink in the label. Is there something obvious that I'm doing wrong?

Many thanks in advance for any help you can provide!