Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Derivatives of restricted items shouldn't be publically accessible #1134

Open
seth-shaw-unlv opened this issue May 29, 2019 · 12 comments
Open
Labels
Subject: Access Control related to managing roles and permissions/information security.

Comments

@seth-shaw-unlv
Copy link
Contributor

I enabled permissions_by_entity (part of permissions_by_term) and created a "Staff Only" term in the "Islandora Access" vocabulary with fcrepo and Authenticated roles selected. I then uploaded a File with the "Staff Only" term. This worked as expected, authenticated users had access but Anonymous users did not.

However, derivatives generated for the item which, theoretically, should also be restricted were publically accessible. I see two possible solutions for this at first glance:

  1. Have derivatives inherit the same permissions as the original file, OR
  2. Don't generate derivatives for restricted content at all.

Other options?

@mjordan
Copy link
Contributor

mjordan commented May 29, 2019

You can detect if a media has a term using a Context condition (see bottom of https://islandora-claw.github.io/CLAW/user-documentation/context/), so if you can assign terms as a Context reaction, we might be able to ship a preconfigured Context to handle this.

@seth-shaw-unlv
Copy link
Contributor Author

@mjordan, so to make this preconfigured we would have to:

  1. Generalize our existing 'Node has term' condition to be 'Entity has term'
  2. Add at least one term to the Islandora Access vocabulary
  3. Configure the 'image_original_file' context to use the new/updated condition and access term.

We should probably do the first one (although probably too late for 1.0) and the other two can be handled by documentation.

@seth-shaw-unlv
Copy link
Contributor Author

seth-shaw-unlv commented May 29, 2019

Pft...whoops. I was looking at the list of available conditions by clicking 'add condition'. That list doesn't include the conditions you are already using. I completely missed the existing media has term condition with the original file term which I can add the new access term.

So, yeah, we only need to add a default term and update the default config. Still probably best done in documentation or as a submodule (although I've had trouble getting submodules to update existing configs).

@seth-shaw-unlv
Copy link
Contributor Author

seth-shaw-unlv commented May 29, 2019

Actually, the inability to add multiple of the same type of condition is problematic for this use case. I would want to add a second media_has_term condition with the 'Staff Only' term that was negated while the original condition is not, but the UI isn't allowing me to do that.

The only way to do it now is to also create an 'Anonymous' access term which would be applied to everything except those with 'Staff Only' access and use the anonymous term in the condition.

We could update the condition to allow each term to be negated or not...

@mjordan
Copy link
Contributor

mjordan commented Jun 5, 2019

Is there a hook that fires when derivatives are created? If so, we could implement it to assign the tags to all derivatives.

@kayakr
Copy link
Contributor

kayakr commented Jun 12, 2019

@seth-shaw-unlv We're using a simple access control mechanism of Media being published/unpublished along with Drupal private files. Any solution using Drupal public file system doesn't stop derivatives being served by the webserver...

@mjordan
Copy link
Contributor

mjordan commented Jun 12, 2019

@kayakr When I configure a term using Permission by Term module to be accessible to have content tagged with it only accessible to specific roles, for example, with this configuration on my term "Private stuff":

taxoconfig

And then add that tag to a media entity, going to either the media's URL (http://localhost:8000/media/100) or the associated file's direct URL on the public filesystem (in this case, http://localhost:8000/_flysystem/fedora/csv_migration/Free%20Smells.jpg) as an anonymous user results in an "Access Denied" response. Toggling Anonymous on and off in the term permissions configuration results in predictable access restrictions on that file.

Am I missing some way of testing this so that an unauthorized user can access that restricted file?

@mjordan
Copy link
Contributor

mjordan commented Jun 12, 2019

Related issue and discussion is #823.

@seth-shaw-unlv
Copy link
Contributor Author

@mjordan files that use the "public://" filesystem descriptor cannot be restricted using Drupal access control mechanisms as they are served directly be the webserver. Files using the "private://" or any Flysystem-based descriptor (such as our "fedora://") can.

@kayakr, it is simple enough to point derivatives at the private filesystem (although this adds system overhead that most of my content doesn't need). How are you determining which published/unpublished status a file should have? In most cases I want my derivatives to be open immediately; it is only the restricted content (a relatively small percentage) that shouldn't be open.

@kayakr
Copy link
Contributor

kayakr commented Jun 13, 2019

@mjordan The explanation from @seth-shaw-unlv is my understanding also; the term might restrict access to the original file on fcrepo via flysystem, but if the derivatives are in Drupal public:// then they can be reached anonymously as Drupal isn't involved in serving them.

@seth-shaw-unlv At the moment content is ingested and defaults to unpublished, including derivative media. They can be bulk-selected in Admin UI and changed to published. We haven't set up any smarter actions about toggling a Repository Item node and all related media to published/unpublished, but that would be nice.
We haven't yet looked at moving files from private:// to public:// when published, though I have done that on D7.

@mjordan
Copy link
Contributor

mjordan commented Jun 13, 2019

@kayakr and @seth-shaw-unlv OK, sorry, I mistakenly thought I had my thumbnail generation configured as per #1037.

@kayakr
Copy link
Contributor

kayakr commented Apr 22, 2020

@mjordan @seth-shaw-unlv FYI, we've been using https://www.drupal.org/project/file_access_fix to move files between private and public storage based on media status published or unpublished. Our default filesystem is Drupal private, so original files go to fedora via flysystem, then derivatives are private unless published, in which case file_access_fix moves them to public and they can be cached via varnish et al.

@kstapelfeldt kstapelfeldt added Subject: Access Control related to managing roles and permissions/information security. and removed Access control labels Sep 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Subject: Access Control related to managing roles and permissions/information security.
Projects
Development

No branches or pull requests

5 participants