hydra-access-controls 5.0.0.pre11 → 5.0.0.pre12
Sign up to get free protection for your applications and to get access to all the features.
- data/hydra-access-controls.gemspec +3 -1
- data/lib/hydra/ability.rb +6 -3
- data/lib/hydra/access_controls_enforcement.rb +10 -4
- data/lib/hydra/admin_policy.rb +1 -3
- data/lib/hydra/user.rb +0 -17
- metadata +4 -4
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
|
|
6
6
|
gem.email = ["hydra-tech@googlegroups.com"]
|
7
7
|
gem.description = %q{Access controls for project hydra}
|
8
8
|
gem.summary = %q{Access controls for project hydra}
|
9
|
-
gem.homepage = ""
|
9
|
+
gem.homepage = "http://projecthydra.org"
|
10
10
|
|
11
11
|
gem.files = `git ls-files`.split($\)
|
12
12
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
@@ -15,6 +15,8 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.require_paths = ["lib"]
|
16
16
|
gem.version = version
|
17
17
|
|
18
|
+
gem.required_ruby_version = '>= 1.9.3'
|
19
|
+
|
18
20
|
gem.add_dependency 'activesupport'
|
19
21
|
gem.add_dependency 'active-fedora'
|
20
22
|
gem.add_dependency 'cancan'
|
data/lib/hydra/ability.rb
CHANGED
@@ -1,8 +1,11 @@
|
|
1
|
-
require "blacklight"
|
2
|
-
# this code will move to lib/hydra/access_controls/ability.rb (with the appropriate namespace changes) in Hydra 5.0
|
3
1
|
# Code for [CANCAN] access to Hydra models
|
4
2
|
module Hydra::Ability
|
5
|
-
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
include Hydra::AccessControlsEnforcement
|
7
|
+
include Blacklight::SolrHelper
|
8
|
+
end
|
6
9
|
|
7
10
|
def self.user_class
|
8
11
|
Hydra.config[:user_model] ? Hydra.config[:user_model].constantize : ::User
|
@@ -1,8 +1,9 @@
|
|
1
1
|
# will move to lib/hydra/access_control folder/namespace in release 5.x
|
2
2
|
module Hydra::AccessControlsEnforcement
|
3
|
+
extend ActiveSupport::Concern
|
3
4
|
|
4
|
-
|
5
|
-
|
5
|
+
included do
|
6
|
+
include Hydra::AccessControlsEvaluation
|
6
7
|
end
|
7
8
|
|
8
9
|
#
|
@@ -53,7 +54,12 @@ module Hydra::AccessControlsEnforcement
|
|
53
54
|
# @param [Hash] extra_controller_params (optional)
|
54
55
|
def get_permissions_solr_response_for_doc_id(id=nil, extra_controller_params={})
|
55
56
|
raise Blacklight::Exceptions::InvalidSolrID.new("The application is trying to retrieve permissions without specifying an asset id") if id.nil?
|
56
|
-
solr_response = Blacklight.solr.
|
57
|
+
#solr_response = Blacklight.solr.get permissions_solr_doc_params(id).merge(extra_controller_params)
|
58
|
+
#path = blacklight_config.solr_path
|
59
|
+
solr_opts = permissions_solr_doc_params(id).merge(extra_controller_params)
|
60
|
+
response = Blacklight.solr.get('select', :params=> solr_opts)
|
61
|
+
solr_response = Blacklight::SolrResponse.new(force_to_utf8(response), solr_opts)
|
62
|
+
|
57
63
|
raise Blacklight::Exceptions::InvalidSolrID.new("The solr permissions search handler didn't return anything for id \"#{id}\"") if solr_response.docs.empty?
|
58
64
|
document = SolrDocument.new(solr_response.docs.first, solr_response)
|
59
65
|
[solr_response, document]
|
@@ -138,7 +144,7 @@ module Hydra::AccessControlsEnforcement
|
|
138
144
|
end
|
139
145
|
|
140
146
|
## proxies to enforce_edit_permssions. This method is here for you to override
|
141
|
-
def
|
147
|
+
def enforce_destroy_permissions(opts={})
|
142
148
|
enforce_edit_permissions(opts)
|
143
149
|
end
|
144
150
|
|
data/lib/hydra/admin_policy.rb
CHANGED
@@ -9,9 +9,7 @@ class Hydra::AdminPolicy < ActiveFedora::Base
|
|
9
9
|
# Uses the Hydra Rights Metadata Schema for tracking access permissions & copyright
|
10
10
|
has_metadata :name => "rightsMetadata", :type => Hydra::Datastream::RightsMetadata
|
11
11
|
|
12
|
-
has_metadata :name =>'descMetadata', :type => ActiveFedora::QualifiedDublinCoreDatastream
|
13
|
-
ds.field :license_url
|
14
|
-
end
|
12
|
+
has_metadata :name =>'descMetadata', :type => ActiveFedora::QualifiedDublinCoreDatastream
|
15
13
|
|
16
14
|
delegate_to :descMetadata, [:title, :description], :unique=>true
|
17
15
|
delegate :license_title, :to=>'rightsMetadata', :at=>[:license, :title], :unique=>true
|
data/lib/hydra/user.rb
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
# Injects behaviors into User model so that it will work with Hydra Access Controls
|
2
2
|
# By default, this module assumes you are using the User model created by Blacklight, which uses Devise.
|
3
3
|
# To integrate your own User implementation into Hydra, override this Module or define your own User model in app/models/user.rb within your Hydra head.
|
4
|
-
require 'deprecation'
|
5
4
|
module Hydra::User
|
6
|
-
extend Deprecation
|
7
5
|
|
8
6
|
def self.included(klass)
|
9
7
|
# Other modules to auto-include
|
@@ -24,19 +22,4 @@ module Hydra::User
|
|
24
22
|
self.send("find_by_#{Devise.authentication_keys.first}".to_sym, key)
|
25
23
|
end
|
26
24
|
end
|
27
|
-
|
28
|
-
# This method should display the unique identifier for this user
|
29
|
-
# the unique identifier is what access controls will be enforced against.
|
30
|
-
def unique_id
|
31
|
-
return to_s
|
32
|
-
end
|
33
|
-
deprecation_deprecate :unique_id
|
34
|
-
|
35
|
-
|
36
|
-
# For backwards compatibility with the Rails2 User models in Hydra/Blacklight
|
37
|
-
def login
|
38
|
-
return unique_id
|
39
|
-
end
|
40
|
-
deprecation_deprecate :login
|
41
|
-
|
42
25
|
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: 5.0.0.
|
4
|
+
version: 5.0.0.pre12
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-
|
14
|
+
date: 2012-11-15 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activesupport
|
@@ -172,7 +172,7 @@ files:
|
|
172
172
|
- spec/unit/policy_aware_access_controls_enforcement_spec.rb
|
173
173
|
- spec/unit/rights_metadata_spec.rb
|
174
174
|
- spec/unit/role_mapper_spec.rb
|
175
|
-
homepage:
|
175
|
+
homepage: http://projecthydra.org
|
176
176
|
licenses: []
|
177
177
|
post_install_message:
|
178
178
|
rdoc_options: []
|
@@ -183,7 +183,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
183
183
|
requirements:
|
184
184
|
- - ! '>='
|
185
185
|
- !ruby/object:Gem::Version
|
186
|
-
version:
|
186
|
+
version: 1.9.3
|
187
187
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
188
188
|
none: false
|
189
189
|
requirements:
|