hydra-access-controls 9.1.4 → 9.2.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/hydra/ability.rb +1 -1
- data/lib/hydra/admin_policy.rb +3 -3
- data/lib/hydra/config.rb +14 -0
- data/spec/unit/ability_spec.rb +29 -11
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 361ce3b1b9ae7f917b0f671b2536f5965950ff28
|
4
|
+
data.tar.gz: 43a7d26a5d9ad1f913b7827ce56abcd4455d7e73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d003ee8f236a5fdc56bbe001e722439023e89d3a9d58b6bb4d6420dca05aa529ba164220b289c8a5e783cdbd3803e2c2d3ad6a626799e5ac58b27f72ef0847b
|
7
|
+
data.tar.gz: abeb83a756abe8e91fe5f88f56e8e35a0918c5e5d27a2ba297868a436778272128474183976c2d61123a64bf86c1c46614fff3ea9bb87a4157fd5f34a4a34e95
|
data/lib/hydra/ability.rb
CHANGED
@@ -90,7 +90,7 @@ module Hydra
|
|
90
90
|
# Download permissions are exercised in Hydra::Controller::DownloadBehavior
|
91
91
|
def download_permissions
|
92
92
|
can :download, ActiveFedora::File do |file|
|
93
|
-
parent_uri = file.uri.sub(/\/[^\/]*$/, '')
|
93
|
+
parent_uri = file.uri.to_s.sub(/\/[^\/]*$/, '')
|
94
94
|
parent_id = ActiveFedora::Base.uri_to_id(parent_uri)
|
95
95
|
can? :read, parent_id # i.e, can download if can read parent resource
|
96
96
|
end
|
data/lib/hydra/admin_policy.rb
CHANGED
@@ -24,15 +24,15 @@ module Hydra
|
|
24
24
|
alias_method_chain :title, :first
|
25
25
|
|
26
26
|
def license_title=(_)
|
27
|
-
Deprecation.warn AdminPolicy, "license_title= has been
|
27
|
+
Deprecation.warn AdminPolicy, "license_title= has been removed from AdminPolicy. Look at Hydra::Rights instead"
|
28
28
|
end
|
29
29
|
|
30
30
|
def license_description=(_)
|
31
|
-
Deprecation.warn AdminPolicy, "
|
31
|
+
Deprecation.warn AdminPolicy, "license_description= has been removed from AdminPolicy. Look at Hydra::Rights instead"
|
32
32
|
end
|
33
33
|
|
34
34
|
def license_url=(_)
|
35
|
-
Deprecation.warn AdminPolicy, "
|
35
|
+
Deprecation.warn AdminPolicy, "license_url= has been removed from AdminPolicy. Look at Hydra::Rights instead"
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
data/lib/hydra/config.rb
CHANGED
@@ -11,6 +11,8 @@ module Hydra
|
|
11
11
|
self.permissions = value
|
12
12
|
when :user_model
|
13
13
|
self.user_model = value
|
14
|
+
when :id_to_resource_uri
|
15
|
+
self.id_to_resource_uri = value
|
14
16
|
else
|
15
17
|
raise "Unknown key"
|
16
18
|
end
|
@@ -22,14 +24,26 @@ module Hydra
|
|
22
24
|
permissions
|
23
25
|
when :user_model
|
24
26
|
user_model
|
27
|
+
when :id_to_resource_uri
|
28
|
+
id_to_resource_uri
|
25
29
|
else
|
26
30
|
raise "Unknown key #{key}"
|
27
31
|
end
|
28
32
|
end
|
29
33
|
|
30
34
|
attr_reader :permissions
|
35
|
+
attr_writer :id_to_resource_uri
|
31
36
|
attr_accessor :user_model
|
32
37
|
|
38
|
+
# This is purely used for translating an ID to user-facing URIs not used for
|
39
|
+
# persistence. Useful for storing RDF in Fedora but displaying their
|
40
|
+
# subjects in content negotiation as local to the application.
|
41
|
+
#
|
42
|
+
# @return [Lambda] a method to convert ID to a URI
|
43
|
+
def id_to_resource_uri
|
44
|
+
@id_to_resource_uri ||= ActiveFedora::Base.translate_id_to_uri
|
45
|
+
end
|
46
|
+
|
33
47
|
def permissions= values
|
34
48
|
@permissions.merge! values
|
35
49
|
end
|
data/spec/unit/ability_spec.rb
CHANGED
@@ -238,24 +238,42 @@ describe Ability do
|
|
238
238
|
subject { Ability.new(user) }
|
239
239
|
let(:asset) { FactoryGirl.create(:asset) }
|
240
240
|
let(:user) { FactoryGirl.build(:user) }
|
241
|
-
let(:file) { ActiveFedora::File.new(
|
241
|
+
let(:file) { ActiveFedora::File.new() }
|
242
242
|
|
243
|
+
before { allow(file).to receive(:uri).and_return(uri) }
|
243
244
|
after { asset.destroy }
|
244
245
|
|
245
|
-
context "
|
246
|
-
|
247
|
-
|
248
|
-
|
246
|
+
context "in AF < 9.2" do
|
247
|
+
let(:uri) { "#{asset.uri}/ds1" }
|
248
|
+
|
249
|
+
context "user has read permission on the object" do
|
250
|
+
before do
|
251
|
+
asset.read_users = [user.user_key]
|
252
|
+
asset.save!
|
253
|
+
end
|
254
|
+
|
255
|
+
it { should be_able_to(:read, asset.id) }
|
256
|
+
it { should be_able_to(:download, file) }
|
249
257
|
end
|
250
258
|
|
251
|
-
|
252
|
-
|
259
|
+
context "user lacks read permission on the object and file" do
|
260
|
+
it { should_not be_able_to(:read, asset) }
|
261
|
+
it { should_not be_able_to(:download, file) }
|
262
|
+
end
|
253
263
|
end
|
254
264
|
|
255
|
-
context "
|
256
|
-
|
257
|
-
|
265
|
+
context "in AF >= 9.2" do
|
266
|
+
let(:uri) { RDF::URI("#{asset.uri}/ds1") }
|
267
|
+
|
268
|
+
context "user has read permission on the object" do
|
269
|
+
before do
|
270
|
+
asset.read_users = [user.user_key]
|
271
|
+
asset.save!
|
272
|
+
end
|
273
|
+
|
274
|
+
it { should be_able_to(:read, asset.id) }
|
275
|
+
it { should be_able_to(:download, file) }
|
276
|
+
end
|
258
277
|
end
|
259
278
|
end
|
260
|
-
|
261
279
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hydra-access-controls
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 9.
|
4
|
+
version: 9.2.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Beer
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-
|
13
|
+
date: 2015-06-30 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -213,12 +213,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
213
213
|
version: 1.9.3
|
214
214
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
215
215
|
requirements:
|
216
|
-
- - "
|
216
|
+
- - ">"
|
217
217
|
- !ruby/object:Gem::Version
|
218
|
-
version:
|
218
|
+
version: 1.3.1
|
219
219
|
requirements: []
|
220
220
|
rubyforge_project:
|
221
|
-
rubygems_version: 2.4.
|
221
|
+
rubygems_version: 2.4.8
|
222
222
|
signing_key:
|
223
223
|
specification_version: 4
|
224
224
|
summary: Access controls for project hydra
|