Install
Works with Drupal: ^11.4 || ^12Using Composer to manage Drupal site dependencies
Alternative installation files
Release notes
Initial beta release. File Gate denies anonymous access to private:// files and delivers them only to visitors who have passed a gate — a lead form, a login, a token — through short-lived signed URLs that work with any front end.
Out of the box, Drupal grants a private-file download to anyone who can view the entity that references it; because anonymous users can view published content, a private file attached to published media is effectively public to anyone who has the link. File Gate closes that gap.
Highlights
- Deny by default. A
hook_file_download()veto forprivate://files referenced by a gated field, for everyone except staff holding the "Bypass file gate" permission. - Decoupled delivery. A trusted back end mints a short-lived, HMAC-signed URL (
POST /api/file-gate/mint) that the browser redeems (GET /api/file-gate/download). Fully front-end-agnostic; the raw/system/filespath stays denied and theprivate://path is never disclosed. - Pluggable gate methods. A
GateMethodplugin type decides how a request proves it passed the gate. Ships with Signed URL (HMAC) and Authenticated access; add your own (token, email capture, one-time password, …). - Per-field configuration. Mark any private file or image field "gated" where you choose its storage; enabling gating forces and locks the private file system.
- Expiry and usage controls. Per-field TTL, an absolute "available until" window, and usage limits — including one-time links. Every constraint is bound into the signature.
- Media-optional. Gate a Media source field, a plain file field, or any other private file field. The only hard dependency is core File.
- Fails closed. With no signing secret configured, minting returns
503and every gated file is denied. - Constant-time verification, a dedicated logging channel (security and usage events), and an admin dashboard (secret status, global defaults, and a gated-field overview).
Requirements
- Drupal 11.4+ (built on core's
FileReferenceResolverAPI). - A configured private file system and a signing secret injected from the environment.
Beta note: the feature set and APIs are complete and covered by kernel tests, but the module has not yet had a stable release or opted into security-advisory coverage. Feedback and issue reports are welcome.