Experimental project

This is a sandbox project, which contains experimental code for developer use only.

Protect files in the drupal private file system using a generated key. Files protected in such a way are only accessible if the key is supplied in the url by means of the file_key url parameter.

API

The filekey module does not expose any user interface but only two methods which can be used by third party modules.

  1. filekey_protect($file, $expire = 0x7FFFFFFF)
    Given a file object (as retrieved from file_load) and an expiry date, protect the file with an automatically generated key. Returns the access key suitable to be supplied into the query-option parameter of the url function.
  2. filekey_unprotect($file)
    Given a file object (as retrieved from file_load) removes the file-key record such that the file may be accessed without supplying the a key.

Requirements

Security Note

The file key is not saved in clear text into the database but rather as a salted hash using by using the secrets module.

Project information