Problem/Motivation
We have an intranet site that uses Acquia DAM to serve assets like images and documents. Currently, the site uses the media_acquiadam module. The file fields on our media types are implemented using the private filesystem. Since that module downloads the file to the server, the proper permissions are maintained. Even if a user were to right click on an image on the site and copy the URL, it would be inaccessible to unauthenticated users.
Does this module support the private filesystem or a similar means for restriction access? While trying to migrate our existing site and assets to acquia_dam, I'm struggling to find a way to set up similar access restrictions. Since there is not a traditional file field, what would be the best way to go about this?
Steps to reproduce
- Set up a site with a connection to Acquia DAM using this module
- Embed an image into your site via the WYSIWYG editor or an entity reference field
- View the media entity
- Right click the image file
- Observe the URL is of the pattern
https://<subdomain>.widen.net/content/gxzcvxtogx/web/test-image-scenario.jpg - Paste this URL into an incognito window
- Observe you are able to see the image without being logged into Drupal
Proposed resolution
- For previous projects, I've implemented an EventSubscriber that returns a BinaryFileResponse when viewing the media entity's canonical path. This obscures the file path on the server and allows a path alias to be used for direct access of the file. I'm able to use a TrustedRedirectResponse with `acquia_dam` but the user is redirected to a Widen CDN link. I could temporarily fetch and save the file to use a BinaryFileResponse, but there could be performance implications.
- I've not developed or implemented a custom stream wrapper, but there may be a possibility of extending it.
Remaining tasks
n/a
User interface changes
n/a
API changes
n/a
Data model changes
n/a
Issue fork acquia_dam-3369081
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
patrickfwestonComment #3
patrickfwestonI was actually able to get a proof of concept working where the path alias of the media entity is used, but the image content is displayed inline in the browser.
Here's what my
EventSubscriberlooks like:Comment #4
mglamanTagging as a feature request, we'll raise internally.
Comment #5
rajeshreeputra@patrickfweston - can you try 1.1.x version with download and sync option enabled?
Comment #6
danflanagan8I'm running into a similar but simpler issue. I need sync'ed files to be stored in the private file system. I tried a
hook_entity_field_storage_info_alterassuming that setting the file field to private would do the trick:No joy. Instead, the
Drupal\acquia_dam\AssetFileEntityHelperclass always uses the default scheme:It would be great if that were either configurable or if it honored the scheme set on the
acquia_dam_managed_filebase field.Comment #7
rajeshreeputraYes, that sounds reasonable to me.
Comment #9
rajeshreeputraRequesting review.
Comment #10
ankitv18 commentedTests are failing, please look into this.
Comment #11
rajeshreeputraUpdated scheme_options with stream wrapper WRITE_VISIBLE options.
Comment #12
japerryLooking very close, added one comment regarding fetching the default uri_scheme ... it appears the logic is duplicated, and it'd be nice to centralize fetching the default.
Comment #14
amangrover90 commentedMerged the changes.