Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
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.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
- Drupal modules: Secrets.
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
- Created by znerol on , updated