Merge branch '5200-anonymous-download'
[arvados.git] / apps / workbench / app / controllers / collections_controller.rb
index 6fcede2808a9b1de7783fbde0793730230d49921..3ef46887d82c24a2edc2e5e6778b1a1fd20769e9 100644 (file)
@@ -4,10 +4,11 @@ class CollectionsController < ApplicationController
   include ActionController::Live
 
   skip_around_filter :require_thread_api_token, if: proc { |ctrl|
-    (Rails.configuration.anonymous_user_token and
-     'show' == ctrl.action_name) or
-    %w(show_file show_file_links).include? ctrl.action_name
+    Rails.configuration.anonymous_user_token and
+    'show' == ctrl.action_name
   }
+  skip_around_filter(:require_thread_api_token,
+                     only: [:show_file, :show_file_links])
   skip_before_filter(:find_object_by_uuid,
                      only: [:provenance, :show_file, :show_file_links])
   # We depend on show_file to display the user agreement:
@@ -119,7 +120,9 @@ class CollectionsController < ApplicationController
     # purposes: it lets us return a useful status code for common errors, and
     # helps us figure out which token to provide to arv-get.
     coll = nil
-    tokens = [Thread.current[:arvados_api_token], params[:reader_token]].compact
+    tokens = [Thread.current[:arvados_api_token],
+              params[:reader_token],
+              (Rails.configuration.anonymous_user_token || nil)].compact
     usable_token = find_usable_token(tokens) do
       coll = Collection.find(params[:uuid])
     end
@@ -295,7 +298,9 @@ class CollectionsController < ApplicationController
     return nil
   end
 
-  def file_enumerator(opts)
+  # Note: several controller and integration tests rely on stubbing
+  # file_enumerator to return fake file content.
+  def file_enumerator opts
     FileStreamer.new opts
   end