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

Location-restricted PDFs do not display in the PDF viewer even at an authorized location #2360

Open
andrewjbtw opened this issue Feb 5, 2025 · 3 comments
Assignees
Labels

Comments

@andrewjbtw
Copy link

andrewjbtw commented Feb 5, 2025

Describe the bug

When at an authorized location, location-restricted PDFs do not open in the viewer. It is possible to download the PDFs from direct links to the Stacks URL but the viewer presentation looks the same as when you are not in an authorized location.

I tested this while on campus visiting the Special Collections reading room. Geoff Willard (@oceanofsound ) also verified this from his workstation that is authorized to view location-restricted materials.

Expected behavior

When at an authorized location, the viewer should present PDFs as if the user has logged in. This is what happens with location-restricted media and images.

Additional information

I'm not sure how we can test this remotely. Whoever picks up the ticket may need to coordinate with Geoff if they need to see what the browser is doing when visiting PDF.

To reproduce

From an authorized location:

  1. Visit this purl.
  2. See that the PDF is not available
  3. Try this Stacks link:
  4. See that the PDF can be downloaded, which means the location-restriction is being applied to the file.

From outside an authorized location:

Follow the steps above and see that neither the PDF viewer nor the Stacks link will allow access to the PDF.

@andrewjbtw andrewjbtw added the bug label Feb 5, 2025
@jcoyne
Copy link
Contributor

jcoyne commented Feb 5, 2025

I believe this is because https://github.com/sul-dlss/sul-embed/blob/main/app/viewers/embed/viewer/pdf_viewer.rb#L37-L39 is returning false

purl_object = Embed::Purl.find('zs884sy8048')
document_resource_files = purl_object.contents.select { |content| content.type == 'document' }.map(&:files).flatten
document_resource_files.first&.downloadable?
# => false

Embed::Purl::ResourceFile#downloadable? requires either world downloadable or stanford only downloadable.

It seems like the PdfComponent is using a completely different auth protocol from the media viewer. Currently it doesn't look like the PDF can handle embargo either. I wonder if switching to the media protocol could fix this?

I thought we did this in #2075.

@dnoneill
Copy link
Contributor

How would I test this without being on campus?

@jcoyne
Copy link
Contributor

jcoyne commented Feb 10, 2025

@dnoneill could you run a local copy of stacks and set your own IP https://github.com/sul-dlss/stacks/blob/main/config/settings.yml#L58 ?

@hudajkhan hudajkhan self-assigned this Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants