digitalutsc / islandora_lite_docs

Contains a Wiki with documentation for the UTSC Library's Islandora Lite System
GNU General Public License v3.0
2 stars 0 forks source link

Access Control #31

Open kstapelfeldt opened 3 years ago

kstapelfeldt commented 3 years ago

(Respecting to the File level)

kstapelfeldt commented 3 years ago

Problem

Need to replicate the functionality of Islandora 7x in the Islandora 2.0 stack

Resources

Research

kstapelfeldt commented 2 years ago

https://www.drupal.org/project/content_access

kstapelfeldt commented 2 years ago

https://www.drupal.org/project/acl

kstapelfeldt commented 2 years ago

https://www.drupal.org/node/270000

kstapelfeldt commented 2 years ago

This module has some inheritance features that might be valuable to review: https://www.drupal.org/project/access_by_ref

kylehuynh205 commented 2 years ago

Drupal Private file system approach:

Demo in PP (VPN on):

By default, the following media are private. the below links are "Access denied" (without login):

File Link In Node level
Audio file directed link http://d9.dsu-pp.server.utsc.utoronto.ca/node/4
PDF file directed link http://d9.dsu-pp.server.utsc.utoronto.ca/node/2
Video file directed link http://d9.dsu-pp.server.utsc.utoronto.ca/node/3
Image file directed link http://d9.dsu-pp.server.utsc.utoronto.ca/node/4

To flip private to public,

Screen Shot 2021-10-28 at 9 21 32 PM

Screen Shot 2021-10-28 at 9 17 28 PM

Assessment

Pro: everything configuration is in the UI, little cmd involved.

Con: The module https://www.drupal.org/project/private_files_download_permission use hook_file_download to check permission of the file, and return a BinaryFileResponse which is a Response Object contains a SplFileInfo File object. With this factor, the loading performance maybe effected if the file is big, or a view contains many objects, or Searching functionality.

TODO:

If we decide to go with this approach, the next development piece is automate the process of add directory the table above.

kylehuynh205 commented 2 years ago

Flysystem Local Adapter Approach:

How to setup:

$settings['flysystem'] = [
  'local' => [ // The name of the stream wrapper.
    'driver' => 'local', // The plugin key.
    'config' => [
      'root' => 'sites/default/flysystem',
      'public' => TRUE,
      'name' => 'islandora_lite', // Defaults to Flysystem: scheme.
      'description' => 'islandora_lite',  // Defaults to Flysystem: scheme.
      'cache' => TRUE, // Cache filesystem metadata. Not necessary for
      'replicate' => 'ftpexample', // 'replicate' writes to both filesystems, but
      'serve_js' => TRUE, // Serve Javascript or CSS via this stream wrapper.
      'serve_css' => TRUE, // This is useful for adapters that function as
    ],
  ],
]

Usage: To apply Private or Public mode to a file, according to Flysystem API at https://flysystem.thephpleague.com/v2/docs/adapter/local/, use command line to change permission:

==> To be implement: Need to organize files uploaded for media in a directory (ie. named with media ID), then set 7604 for private and 0740 for public.

Assessment:

Pro:

Con: No interface available, use more in command-line

kylehuynh205 commented 2 years ago

Embargos (alternative to Permission by term):

Example: http://d9.dsu-pp.server.utsc.utoronto.ca/node/5/embargoes

Add embargos to the above node:

kstapelfeldt commented 2 years ago

Drupal groups seems to provide a solution, but we need to be able to hide selected media (putting media in groups)

kylehuynh205 commented 2 years ago

Found that File Entity and Group have a conflict on handling the access control for Private File system.

image

image

In fact, we use the File Entity module for Fits. so it usually comes to our sites by default (if the sites needs Fits). If we also use Group to handle more use cases for access control in the same sites, these two module can cause the conflict. To solve that, have to cancel Access control handler in File Entity with this manual fix (for now):

UPDATE:

Solve the issue with a patch: https://github.com/digitalutsc/override_permission_file_entity

kylehuynh205 commented 2 years ago

Deployment has been built into installation process: https://github.com/digitalutsc/islandora_lite_installation/blob/main/scripts/access_control.sh

kylehuynh205 commented 7 months ago

Include this in the config sync deployment