ddr-models 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ddr-models
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Coble
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-11-06 00:00:00.000000000 Z
12
+ date: 2014-11-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -269,31 +269,23 @@ files:
269
269
  - config/initializers/active_fedora_datastream.rb
270
270
  - config/initializers/ddr.rb
271
271
  - config/initializers/devise.rb
272
- - config/initializers/devise.rb~
273
272
  - config/initializers/subscriptions.rb
274
273
  - config/routes.rb
275
274
  - db/migrate/20141021233359_create_events.rb
276
275
  - db/migrate/20141021234156_create_minted_ids.rb
277
276
  - db/migrate/20141103192146_create_workflow_state.rb
278
277
  - db/migrate/20141104181418_create_users.rb
279
- - db/migrate/20141104181418_create_users.rb~
278
+ - db/migrate/20141107124012_add_columns_to_user.rb
280
279
  - lib/ddr-models.rb
281
280
  - lib/ddr/actions.rb
282
281
  - lib/ddr/actions/fixity_check.rb
283
282
  - lib/ddr/auth.rb
284
- - lib/ddr/auth.rb~
285
283
  - lib/ddr/auth/ability.rb
286
- - lib/ddr/auth/ability.rb~
287
284
  - lib/ddr/auth/group_service.rb
288
- - lib/ddr/auth/group_service.rb~
289
285
  - lib/ddr/auth/grouper_service.rb
290
- - lib/ddr/auth/grouper_service.rb~
291
286
  - lib/ddr/auth/remote_group_service.rb
292
- - lib/ddr/auth/remote_group_service.rb~
293
287
  - lib/ddr/auth/superuser.rb
294
- - lib/ddr/auth/superuser.rb~
295
288
  - lib/ddr/auth/user.rb
296
- - lib/ddr/auth/user.rb~
297
289
  - lib/ddr/configurable.rb
298
290
  - lib/ddr/datastreams.rb
299
291
  - lib/ddr/datastreams/content_metadata_datastream.rb
@@ -397,8 +389,6 @@ files:
397
389
  - spec/factories/target_factories.rb
398
390
  - spec/factories/test_model_factories.rb
399
391
  - spec/factories/user_factories.rb
400
- - spec/factories/user_factories.rb~
401
- - spec/features/grouper_integration_spec.rb~
402
392
  - spec/fixtures/contentMetadata.xml
403
393
  - spec/fixtures/image1.tiff
404
394
  - spec/fixtures/image2.tiff
@@ -408,7 +398,6 @@ files:
408
398
  - spec/fixtures/sample.pdf
409
399
  - spec/fixtures/target.png
410
400
  - spec/models/ability_spec.rb
411
- - spec/models/ability_spec.rb~
412
401
  - spec/models/active_fedora_base_spec.rb
413
402
  - spec/models/active_fedora_datastream_spec.rb
414
403
  - spec/models/attachment_spec.rb
@@ -423,12 +412,9 @@ files:
423
412
  - spec/models/permanent_identification_spec.rb
424
413
  - spec/models/role_assignments_datastream_spec.rb
425
414
  - spec/models/superuser_spec.rb
426
- - spec/models/superuser_spec.rb~
427
415
  - spec/models/target_spec.rb
428
416
  - spec/models/user_spec.rb
429
- - spec/models/user_spec.rb~
430
417
  - spec/services/group_service_spec.rb
431
- - spec/services/group_service_spec.rb~
432
418
  - spec/services/id_service_spec.rb
433
419
  - spec/spec_helper.rb
434
420
  - spec/support/shared_examples_for_access_controllables.rb
@@ -515,8 +501,6 @@ test_files:
515
501
  - spec/factories/target_factories.rb
516
502
  - spec/factories/test_model_factories.rb
517
503
  - spec/factories/user_factories.rb
518
- - spec/factories/user_factories.rb~
519
- - spec/features/grouper_integration_spec.rb~
520
504
  - spec/fixtures/contentMetadata.xml
521
505
  - spec/fixtures/image1.tiff
522
506
  - spec/fixtures/image2.tiff
@@ -526,7 +510,6 @@ test_files:
526
510
  - spec/fixtures/sample.pdf
527
511
  - spec/fixtures/target.png
528
512
  - spec/models/ability_spec.rb
529
- - spec/models/ability_spec.rb~
530
513
  - spec/models/active_fedora_base_spec.rb
531
514
  - spec/models/active_fedora_datastream_spec.rb
532
515
  - spec/models/attachment_spec.rb
@@ -541,12 +524,9 @@ test_files:
541
524
  - spec/models/permanent_identification_spec.rb
542
525
  - spec/models/role_assignments_datastream_spec.rb
543
526
  - spec/models/superuser_spec.rb
544
- - spec/models/superuser_spec.rb~
545
527
  - spec/models/target_spec.rb
546
528
  - spec/models/user_spec.rb
547
- - spec/models/user_spec.rb~
548
529
  - spec/services/group_service_spec.rb
549
- - spec/services/group_service_spec.rb~
550
530
  - spec/services/id_service_spec.rb
551
531
  - spec/spec_helper.rb
552
532
  - spec/support/shared_examples_for_access_controllables.rb
@@ -1,245 +0,0 @@
1
- require 'devise'
2
-
3
- # Use this hook to configure devise mailer, warden hooks and so forth.
4
- # Many of these configuration options can be set straight in your model.
5
- Devise.setup do |config|
6
-
7
- # Given the modules that we implement, this shouldn't be used, but Devise >= 3.1 requires it,
8
- # so a random value should suffice.
9
- config.secret_key = SecureRandom.hex(64)
10
-
11
- # ==> Mailer Configuration
12
- # Configure the e-mail address which will be shown in Devise::Mailer,
13
- # note that it will be overwritten if you use your own mailer class with default "from" parameter.
14
- config.mailer_sender = "lib-drs@duke.edu"
15
-
16
- # Configure the class responsible to send e-mails.
17
- # config.mailer = "Devise::Mailer"
18
-
19
- # ==> ORM configuration
20
- # Load and configure the ORM. Supports :active_record (default) and
21
- # :mongoid (bson_ext recommended) by default. Other ORMs may be
22
- # available as additional gems.
23
- require 'devise/orm/active_record'
24
-
25
- # ==> Configuration for any authentication mechanism
26
- # Configure which keys are used when authenticating a user. The default is
27
- # just :email. You can configure it to use [:username, :subdomain], so for
28
- # authenticating a user, both parameters are required. Remember that those
29
- # parameters are used only when authenticating and not when retrieving from
30
- # session. If you need permissions, you should implement that in a before filter.
31
- # You can also supply a hash where the value is a boolean determining whether
32
- # or not authentication should be aborted when the value is not present.
33
- config.authentication_keys = [ :username ]
34
-
35
- # Configure parameters from the request object used for authentication. Each entry
36
- # given should be a request method and it will automatically be passed to the
37
- # find_for_authentication method and considered in your model lookup. For instance,
38
- # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
39
- # The same considerations mentioned for authentication_keys also apply to request_keys.
40
- # config.request_keys = []
41
-
42
- # Configure which authentication keys should be case-insensitive.
43
- # These keys will be downcased upon creating or modifying a user and when used
44
- # to authenticate or find a user. Default is :email.
45
- config.case_insensitive_keys = [ :username ]
46
-
47
- # Configure which authentication keys should have whitespace stripped.
48
- # These keys will have whitespace before and after removed upon creating or
49
- # modifying a user and when used to authenticate or find a user. Default is :email.
50
- config.strip_whitespace_keys = [ :username ]
51
-
52
- # Tell if authentication through request.params is enabled. True by default.
53
- # It can be set to an array that will enable params authentication only for the
54
- # given strategies, for example, `config.params_authenticatable = [:database]` will
55
- # enable it only for database (email + password) authentication.
56
- config.params_authenticatable = [:database]
57
-
58
- # Tell if authentication through HTTP Basic Auth is enabled. False by default.
59
- # It can be set to an array that will enable http authentication only for the
60
- # given strategies, for example, `config.http_authenticatable = [:token]` will
61
- # enable it only for token authentication.
62
- # config.http_authenticatable = false
63
-
64
- # If http headers should be returned for AJAX requests. True by default.
65
- # config.http_authenticatable_on_xhr = true
66
-
67
- # The realm used in Http Basic Authentication. "Application" by default.
68
- # config.http_authentication_realm = "Application"
69
-
70
- # It will change confirmation, password recovery and other workflows
71
- # to behave the same regardless if the e-mail provided was right or wrong.
72
- # Does not affect registerable.
73
- # config.paranoid = true
74
-
75
- # By default Devise will store the user in session. You can skip storage for
76
- # :http_auth and :token_auth by adding those symbols to the array below.
77
- # Notice that if you are skipping storage for all authentication paths, you
78
- # may want to disable generating routes to Devise's sessions controller by
79
- # passing :skip => :sessions to `devise_for` in your config/routes.rb
80
- config.skip_session_storage = [:http_auth]
81
-
82
- # ==> Configuration for :database_authenticatable
83
- # For bcrypt, this is the cost for hashing the password and defaults to 10. If
84
- # using other encryptors, it sets how many times you want the password re-encrypted.
85
- #
86
- # Limiting the stretches to just one in testing will increase the performance of
87
- # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
88
- # a value less than 10 in other environments.
89
- config.stretches = Rails.env.test? ? 1 : 10
90
-
91
- # Setup a pepper to generate the encrypted password.
92
- # config.pepper = "37669e0c50042b93e63f790c4102864bace2ee0a30eecad6fca7d490f3124d855d8bc6d2978e5500fb266aab2b8c8003d9f202a1f23e4c2c8e8f105b7c46a68f"
93
-
94
- # ==> Configuration for :confirmable
95
- # A period that the user is allowed to access the website even without
96
- # confirming his account. For instance, if set to 2.days, the user will be
97
- # able to access the website for two days without confirming his account,
98
- # access will be blocked just in the third day. Default is 0.days, meaning
99
- # the user cannot access the website without confirming his account.
100
- # config.allow_unconfirmed_access_for = 2.days
101
-
102
- # If true, requires any email changes to be confirmed (exactly the same way as
103
- # initial account confirmation) to be applied. Requires additional unconfirmed_email
104
- # db field (see migrations). Until confirmed new email is stored in
105
- # unconfirmed email column, and copied to email column on successful confirmation.
106
- config.reconfirmable = true
107
-
108
- # Defines which key will be used when confirming an account
109
- config.confirmation_keys = [ :username ]
110
-
111
- # ==> Configuration for :rememberable
112
- # The time the user will be remembered without asking for credentials again.
113
- # config.remember_for = 2.weeks
114
-
115
- # If true, extends the user's remember period when remembered via cookie.
116
- # config.extend_remember_period = false
117
-
118
- # Options to be passed to the created cookie. For instance, you can set
119
- # :secure => true in order to force SSL only cookies.
120
- # config.rememberable_options = {}
121
-
122
- # ==> Configuration for :validatable
123
- # Range for password length. Default is 6..128.
124
- # config.password_length = 6..128
125
-
126
- # Email regex used to validate email formats. It simply asserts that
127
- # an one (and only one) @ exists in the given string. This is mainly
128
- # to give user feedback and not to assert the e-mail validity.
129
- # config.email_regexp = /\A[^@]+@[^@]+\z/
130
-
131
- # ==> Configuration for :timeoutable
132
- # The time you want to timeout the user session without activity. After this
133
- # time the user will be asked for credentials again. Default is 30 minutes.
134
- # config.timeout_in = 30.minutes
135
-
136
- # If true, expires auth token on session timeout.
137
- # config.expire_auth_token_on_timeout = false
138
-
139
- # ==> Configuration for :lockable
140
- # Defines which strategy will be used to lock an account.
141
- # :failed_attempts = Locks an account after a number of failed attempts to sign in.
142
- # :none = No lock strategy. You should handle locking by yourself.
143
- # config.lock_strategy = :failed_attempts
144
-
145
- # Defines which key will be used when locking and unlocking an account
146
- config.unlock_keys = [ :username ]
147
-
148
- # Defines which strategy will be used to unlock an account.
149
- # :email = Sends an unlock link to the user email
150
- # :time = Re-enables login after a certain amount of time (see :unlock_in below)
151
- # :both = Enables both strategies
152
- # :none = No unlock strategy. You should handle unlocking by yourself.
153
- # config.unlock_strategy = :both
154
-
155
- # Number of authentication tries before locking an account if lock_strategy
156
- # is failed attempts.
157
- # config.maximum_attempts = 20
158
-
159
- # Time interval to unlock the account if :time is enabled as unlock_strategy.
160
- # config.unlock_in = 1.hour
161
-
162
- # ==> Configuration for :recoverable
163
- #
164
- # Defines which key will be used when recovering the password for an account
165
- config.reset_password_keys = [ :username ]
166
-
167
- # Time interval you can reset your password with a reset password key.
168
- # Don't put a too small interval or your users won't have the time to
169
- # change their passwords.
170
- config.reset_password_within = 6.hours
171
-
172
- # ==> Configuration for :encryptable
173
- # Allow you to use another encryption algorithm besides bcrypt (default). You can use
174
- # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
175
- # :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
176
- # and :restful_authentication_sha1 (then you should set stretches to 10, and copy
177
- # REST_AUTH_SITE_KEY to pepper)
178
- # config.encryptor = :sha512
179
-
180
- # ==> Configuration for :token_authenticatable
181
- # Defines name of the authentication token params key
182
- # config.token_authentication_key = :auth_token
183
-
184
- # ==> Scopes configuration
185
- # Turn scoped views on. Before rendering "sessions/new", it will first check for
186
- # "users/sessions/new". It's turned off by default because it's slower if you
187
- # are using only default views.
188
- # config.scoped_views = false
189
-
190
- # Configure the default scope given to Warden. By default it's the first
191
- # devise role declared in your routes (usually :user).
192
- # config.default_scope = :user
193
-
194
- # Set this configuration to false if you want /users/sign_out to sign out
195
- # only the current scope. By default, Devise signs out all scopes.
196
- # config.sign_out_all_scopes = true
197
-
198
- # ==> Navigation configuration
199
- # Lists the formats that should be treated as navigational. Formats like
200
- # :html, should redirect to the sign in page when the user does not have
201
- # access, but formats like :xml or :json, should return 401.
202
- #
203
- # If you have any extra navigational formats, like :iphone or :mobile, you
204
- # should add them to the navigational formats lists.
205
- #
206
- # The "*/*" below is required to match Internet Explorer requests.
207
- # config.navigational_formats = ["*/*", :html]
208
-
209
- # The default HTTP method used to sign out a resource. Default is :delete.
210
- config.sign_out_via = :get
211
-
212
- # ==> OmniAuth
213
- # Add a new OmniAuth provider. Check the wiki for more information on setting
214
- # up on your models and hooks.
215
- # config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'
216
-
217
- # ==> Warden configuration
218
- # If you want to use other strategies, that are not supported by Devise, or
219
- # change the failure app, you can configure them inside the config.warden block.
220
- #
221
- # config.warden do |manager|
222
- # manager.intercept_401 = false
223
- # manager.default_strategies(:scope => :user).unshift :remote_user_authenticatable
224
- # end
225
-
226
- config.warden do |manager|
227
- # :superuser scope
228
- manager.serialize_into_session(:superuser) { |superuser| superuser.id }
229
- manager.serialize_from_session(:superuser) { |id| User.find(id) }
230
- end
231
-
232
- # ==> Mountable engine configurations
233
- # When using Devise inside an engine, let's call it `MyEngine`, and this engine
234
- # is mountable, there are some extra configurations to be taken into account.
235
- # The following options are available, assuming the engine is mounted as:
236
- #
237
- # mount MyEngine, at: "/my_engine"
238
- #
239
- # The router that invoked `devise_for`, in the example above, would be:
240
- # config.router_name = :my_engine
241
- #
242
- # When using omniauth, Devise cannot automatically set Omniauth path,
243
- # so you need to do it manually. For the users scope, it would be:
244
- # config.omniauth_path_prefix = "/my_engine/users/auth"
245
- end
@@ -1,6 +0,0 @@
1
- class CreateUsers < ActiveRecord::Migration
2
- def change
3
- create_table :users do |t|
4
- end
5
- end
6
- end
data/lib/ddr/auth.rb~ DELETED
@@ -1,47 +0,0 @@
1
- module Ddr
2
- module Auth
3
- extend ActiveSupport::Autoload
4
-
5
- autoload :User
6
- autoload :Superuser
7
- autoload :Ability
8
- autoload :GroupService
9
- autoload :GrouperService
10
- autoload :RemoteGroupService
11
-
12
- # Superuser group
13
- mattr_accessor :superuser_group do
14
- ENV['SUPERUSER_GROUP']
15
- end
16
-
17
- ## Remote groups (i.e., Grouper) config settings
18
- # request.env key for group memberships
19
- mattr_accessor :remote_groups_env_key do
20
- "ismemberof"
21
- end
22
-
23
- # request.env value internal delimiter
24
- mattr_accessor :remote_groups_env_value_delim do
25
- ";"
26
- end
27
-
28
- # pattern/repl for converting request.env membership values to proper (Grouper) group names
29
- mattr_accessor :remote_groups_env_value_sub do
30
- [/^urn:mace:duke\.edu:groups/, "duke"]
31
- end
32
-
33
- # Filter for getting list of remote groups for the repository - String, not Regexp
34
- mattr_accessor :remote_groups_name_filter do
35
- "duke:library:repository:ddr:"
36
- end
37
-
38
- mattr_accessor :everyone_group do
39
- "public"
40
- end
41
-
42
- mattr_accessor :authenticated_users_group do
43
- "registered"
44
- end
45
-
46
- end
47
- end
@@ -1,204 +0,0 @@
1
- module Ddr
2
- module Auth
3
- class Ability
4
-
5
- include Hydra::PolicyAwareAbility
6
-
7
- def custom_permissions
8
- action_aliases
9
- discover_permissions
10
- export_sets_permissions
11
- events_permissions
12
- batches_permissions
13
- ingest_folders_permissions
14
- metadata_files_permissions
15
- attachment_permissions
16
- children_permissions
17
- upload_permissions
18
- end
19
-
20
- def action_aliases
21
- # read aliases
22
- alias_action :attachments, :collection_info, :components, :event, :events, :items, :targets, to: :read
23
- # edit/update aliases
24
- alias_action :permissions, :default_permissions, to: :update
25
- end
26
-
27
- def read_permissions
28
- super
29
- can :read, ActiveFedora::Datastream do |ds|
30
- can? :read, ds.pid
31
- end
32
- end
33
-
34
- def edit_permissions
35
- super
36
- can [:edit, :update, :destroy], ActiveFedora::Datastream do |action, ds|
37
- can? action, ds.pid
38
- end
39
- end
40
-
41
- def export_sets_permissions
42
- can :create, ExportSet if authenticated_user?
43
- can :manage, ExportSet, user: current_user
44
- end
45
-
46
- def events_permissions
47
- can :read, Ddr::Events::Event, user: current_user
48
- can :read, Ddr::Events::Event do |e|
49
- can? :read, e.pid
50
- end
51
- end
52
-
53
- def batches_permissions
54
- can :manage, DulHydra::Batch::Models::Batch, :user_id => current_user.id
55
- can :manage, DulHydra::Batch::Models::BatchObject do |batch_object|
56
- can? :manage, batch_object.batch
57
- end
58
- end
59
-
60
- def ingest_folders_permissions
61
- can :create, IngestFolder if IngestFolder.permitted_folders(current_user).present?
62
- can [:show, :procezz], IngestFolder, user: current_user
63
- end
64
-
65
- def metadata_files_permissions
66
- can [:show, :procezz], MetadataFile, user: current_user
67
- end
68
-
69
- def download_permissions
70
- can :download, ActiveFedora::Base do |obj|
71
- if obj.is_a? Component
72
- can?(:edit, obj) || (can?(:read, obj) && current_user.has_role?(obj, :downloader))
73
- else
74
- can? :read, obj
75
- end
76
- end
77
- can :download, SolrDocument do |doc|
78
- if doc.active_fedora_model == "Component"
79
- can?(:edit, doc) || (can?(:read, doc) && current_user.has_role?(doc, :downloader))
80
- else
81
- can? :read, doc
82
- end
83
- end
84
- can :download, ActiveFedora::Datastream do |ds|
85
- if ds.dsid == Ddr::Datastreams::CONTENT and ds.digital_object.original_class == Component
86
- can?(:edit, ds.pid) || (can?(:read, ds.pid) && current_user.has_role?(solr_doc(ds.pid), :downloader))
87
- else
88
- can? :read, ds.pid
89
- end
90
- end
91
- end
92
-
93
- def upload_permissions
94
- can :upload, Ddr::Models::HasContent do |obj|
95
- can?(:edit, obj)
96
- end
97
- end
98
-
99
- def children_permissions
100
- can :add_children, Ddr::Models::HasChildren do |obj|
101
- can?(:edit, obj)
102
- end
103
- end
104
-
105
- # Mimics Hydra::Ability#read_permissions
106
- def discover_permissions
107
- can :discover, String do |pid|
108
- test_discover(pid)
109
- end
110
-
111
- can :discover, ActiveFedora::Base do |obj|
112
- test_discover(obj.pid)
113
- end
114
-
115
- can :discover, SolrDocument do |obj|
116
- cache.put(obj.id, obj)
117
- test_discover(obj.id)
118
- end
119
- end
120
-
121
- def attachment_permissions
122
- can :add_attachment, Ddr::Models::HasAttachments do |obj|
123
- can?(:edit, obj)
124
- end
125
- end
126
-
127
- # Mimics Hydra::Ability#test_read + Hydra::PolicyAwareAbility#test_read in one method
128
- def test_discover(pid)
129
- Rails.logger.debug("[CANCAN] Checking discover permissions for user: #{current_user.user_key} with groups: #{user_groups.inspect}")
130
- group_intersection = user_groups & discover_groups(pid)
131
- result = !group_intersection.empty? || discover_persons(pid).include?(current_user.user_key)
132
- result || test_discover_from_policy(pid)
133
- end
134
-
135
- # Mimics Hydra::PolicyAwareAbility#test_read_from_policy
136
- def test_discover_from_policy(object_pid)
137
- policy_pid = policy_pid_for(object_pid)
138
- if policy_pid.nil?
139
- return false
140
- else
141
- Rails.logger.debug("[CANCAN] -policy- Does the POLICY #{policy_pid} provide DISCOVER permissions for #{current_user.user_key}?")
142
- group_intersection = user_groups & discover_groups_from_policy(policy_pid)
143
- result = !group_intersection.empty? || discover_persons_from_policy(policy_pid).include?(current_user.user_key)
144
- Rails.logger.debug("[CANCAN] -policy- decision: #{result}")
145
- result
146
- end
147
- end
148
-
149
- # Mimics Hydra::Ability#read_groups
150
- def discover_groups(pid)
151
- doc = permissions_doc(pid)
152
- return [] if doc.nil?
153
- dg = edit_groups(pid) | read_groups(pid) | (doc[self.class.discover_group_field] || [])
154
- Rails.logger.debug("[CANCAN] discover_groups: #{dg.inspect}")
155
- return dg
156
- end
157
-
158
- # Mimics Hydra::PolicyAwareAbility#read_groups_from_policy
159
- def discover_groups_from_policy(policy_pid)
160
- policy_permissions = policy_permissions_doc(policy_pid)
161
- discover_group_field = Hydra.config[:permissions][:inheritable][:discover][:group]
162
- dg = edit_groups_from_policy(policy_pid) | read_groups_from_policy(policy_pid) | ((policy_permissions == nil || policy_permissions.fetch(discover_group_field, nil) == nil) ? [] : policy_permissions.fetch(discover_group_field, nil))
163
- Rails.logger.debug("[CANCAN] -policy- discover_groups: #{dg.inspect}")
164
- return dg
165
- end
166
-
167
- # Mimics Hydra::Ability#read_persons
168
- def discover_persons(pid)
169
- doc = permissions_doc(pid)
170
- return [] if doc.nil?
171
- dp = edit_persons(pid) | read_persons(pid) | (doc[self.class.discover_person_field] || [])
172
- Rails.logger.debug("[CANCAN] discover_persons: #{dp.inspect}")
173
- return dp
174
- end
175
-
176
- def discover_persons_from_policy(policy_pid)
177
- policy_permissions = policy_permissions_doc(policy_pid)
178
- discover_individual_field = Hydra.config[:permissions][:inheritable][:discover][:individual]
179
- dp = edit_persons_from_policy(policy_pid) | read_persons_from_policy(policy_pid) | ((policy_permissions == nil || policy_permissions.fetch(discover_individual_field, nil) == nil) ? [] : policy_permissions.fetch(discover_individual_field, nil))
180
- Rails.logger.debug("[CANCAN] -policy- discover_persons: #{dp.inspect}")
181
- return dp
182
- end
183
-
184
- def self.discover_person_field
185
- Hydra.config[:permissions][:discover][:individual]
186
- end
187
-
188
- def self.discover_group_field
189
- Hydra.config[:permissions][:discover][:group]
190
- end
191
-
192
- private
193
-
194
- def authenticated_user?
195
- current_user.persisted?
196
- end
197
-
198
- def solr_doc(pid)
199
- SolrDocument.new(ActiveFedora::SolrService.query("id:\"#{pid}\"", rows: 1).first)
200
- end
201
-
202
- end
203
- end
204
- end