-
Notifications
You must be signed in to change notification settings - Fork 124
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
can?(:download, file_set) always returns false (display_media_download_link? in Hyrax::FileSetHelper) #5241
Comments
@cudevmaxwell Thanks for writing up the issue and including the place in the code that seems likely to be part of the problem. I wonder if you can add a bit more information. Specifically, it would be helpful to have
It seems like that config should be related to this problem, but some exploration would be required to do some digging to be sure. |
In a vanilla Hyrax 3.1.0 based app, the download link below the thumbnail in a work display isn't displayed for public users. More information here; https://groups.google.com/g/samvera-tech/c/TBwHy7XbuKE If I add some logging to def display_media_download_link?(file_set:)
Rails.logger.debug "Issue#5241 - Hyrax.config.display_media_download_link?: %s" % Hyrax.config.display_media_download_link?
Rails.logger.debug "Issue#5241 - can?(:download, file_set): %s" % can?(:download, file_set)
Rails.logger.debug "Issue#5241 - !workflow_restriction?(file_set.try(:parent)): %s" % !workflow_restriction?(file_set.try(:parent))
Hyrax.config.display_media_download_link? &&
can?(:download, file_set) &&
!workflow_restriction?(file_set.try(:parent))
end On the left, a logged in user. On the right, a public user, not logged in. The representative media is a public PDF on a public work. The thumbnail and link are generated by <% if display_media_download_link?(file_set: file_set) %>
<div>
<h2 class="sr-only"><%= t('hyrax.file_set.show.downloadable_content.heading') %></h2>
<%= image_tag thumbnail_url(file_set),
class: "representative-media",
alt: "",
role: "presentation" %>
<%= link_to t('hyrax.file_set.show.downloadable_content.pdf_link'),
hyrax.download_path(file_set),
target: :_blank,
id: "file_download",
data: { label: file_set.id } %>
</div>
<% else %>
<div>
<%= image_tag thumbnail_url(file_set),
class: "representative-media",
alt: "",
role: "presentation" %>
</div>
<% end %>
The link isn't added if Also, in production.log, I can see that
vs
|
I've submitted a PR for this issue, which uses The ability is defined in def download_permissions
can :download, String do |id|
test_download(id)
end
can :download, SolrDocument do |obj|
cache.put(obj.id, obj)
test_download(obj.id)
end
end Maybe the |
Closed PR due to failing tests. I'll wait to see if others think this is a legitimate bug, and if my fix is appropriate. If so, I'll rewrite the tests and submit a new PR. |
thanks again for this @cudevmaxwell. it does seem to me all of i'm noting that a def download_permissions
can :download, String do |id|
test_download(id)
end
can :download, [SolrDocument, FileSet] do |obj|
cache.put(obj.id, obj)
test_download(obj.id)
end
end if so, i'd think that would be a good fix. even in that case though, i'm still left wondering why this issue is emerging for you now, but not before this, and i think some further digging is called for if you have the capacity. could you possibly add a stacktrace in a comment here (i'm curious what the call chain leading us here looks like)? additionally, it might be helpful to pass along some further debugging info; something like: Rails.logger.debug "Issue#5241 - file_set class: #{file_set.class}"
Rails.logger.debug "Issue#5241 - file_set id: #{file_set.id}" in the meanwhile, i can dig in on my own app and on |
ah, so i took the liberty of looking at (what i think is) your hyrax app, and i'm noticing that the caller is your own custom view. i don't see exactly where things are going differently on your app's side (how is your hyrax/spec/helpers/hyrax/file_set_helper_spec.rb Lines 17 to 21 in 3de688a
Hyrax::Ability that's got it wrong.
would you like to work together on a fix? |
@no-reply Thanks for looking into this!
|
Where I'm getting stuck is: how should <% if can?(:download, file_set.id) && !(can?(:edit, file_set.id) || can?(:destroy, file_set.id)) %> but in if can? :edit, presenter.solr_document is used. |
When |
wasn't me! it's supposed to redeploy from the latest hyrax
it still seems to me like the |
it does seem like this should already be handling this case: https://github.com/samvera/hyrax/blob/main/app/models/concerns/hyrax/ability.rb#L420-L421 i'm looking into why it's not. |
confirming that this is a bug introduced in 3.1.0. working on a fix now. |
the mistaken namespacing of `::SolrDocument` led to mistakenly restricted authentication on SolrDocument download. where `can?(:download, id)` had the expected behavior `can?(:download, solr_document)` gave `false` in all cases. this bug in `Ability` had been present for some time. beginning in Hyrax 3.1.0, we rely on this permission to be correct, so the visible in that release. this issue was reported as #5241.
the mistaken namespacing of `::SolrDocument` led to mistakenly restricted authentication on SolrDocument download. where `can?(:download, id)` had the expected behavior `can?(:download, solr_document)` gave `false` in all cases. this bug in `Ability` had been present for some time. beginning in Hyrax 3.1.0, we rely on this permission to be correct, so the visible in that release. this issue was reported as #5241.
the mistaken namespacing of `::SolrDocument` led to mistakenly restricted authentication on SolrDocument download. where `can?(:download, id)` had the expected behavior `can?(:download, solr_document)` gave `false` in all cases. this bug in `Ability` had been present for some time. beginning in Hyrax 3.1.0, we rely on this permission to be correct, so the visible in that release. this issue was reported as #5241.
@cudevmaxwell i wonder if this one will take care of it for you? #5250 |
FYI... nurax-stable deploys the latest stable release (currently 3.1.0). nurax-dev is supposed to deploy |
@MPLSFedResearchTZ tested on nurax-dev and verified that the download link is available and working for PDF files. |
hyrax/app/helpers/hyrax/file_set_helper.rb
Line 12 in 97f4560
This call to
can?(:download, file_set)
always returned 'false' in our testing, which was preventing the download link from appearing below thumbnails on work pages.I believe the call should be rewritten to
can?(:download, file_set.id)
, like inapp/views/hyrax/file_sets/_actions.html.erb
.The text was updated successfully, but these errors were encountered: