diff --git a/.travis.yml b/.travis.yml index b765459..df1def0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,8 +2,10 @@ dist: trusty language: ruby cache: bundler sudo: false -script: +install: + - jruby -S gem install bundler -v 2.0.1 - jruby -S bundle install +script: - jruby -S bundle exec rake jdk: - oraclejdk8 diff --git a/lib/delegates.rb b/lib/delegates.rb index f20d956..c61bd24 100644 --- a/lib/delegates.rb +++ b/lib/delegates.rb @@ -51,6 +51,38 @@ class CustomDelegate # attr_accessor :context + ## + # Returns authorization status for the current request. Will be called upon + # all requests to all public endpoints. + # + # Implementations should assume that the underlying resource is available, + # and not try to check for it. + # + # Possible return values: + # + # 1. Boolean true/false, indicating whether the request is fully authorized + # or not. If false, the client will receive a 403 Forbidden response. + # 2. Hash with a `status_code` key. + # a. If it corresponds to an integer from 200-299, the request is + # authorized. + # b. If it corresponds to an integer from 300-399: + # i. If the hash also contains a `location` key corresponding to a + # URI string, the request will be redirected to that URI using + # that code. + # ii. If the hash also contains `scale_numerator` and + # `scale_denominator` keys, the request will be + # redirected using that code to a virtual reduced-scale version of + # the source image. + # c. If it corresponds to 401, the hash must include a `challenge` key + # corresponding to a WWW-Authenticate header value. + # + # @param options [Hash] Empty hash. + # @return [Boolean,Hash] See above. + # + def authorize(options = {}) + authorized?(options) + end + ## # Tells the server whether to redirect in response to the request. Will be # called upon all image requests. @@ -103,7 +135,12 @@ def extra_iiif2_information_response_keys(_options = {}) # @return [String] Source name. # def source(_options = {}) - 'HttpSource' + identifier = context['identifier'] + if identifier.start_with?('Masters/') + 'FilesystemSource' + else + 'HttpSource' + end end ##