ddr-models 2.11.0 → 3.0.0.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/.travis.yml +7 -6
- data/Gemfile +2 -3
- data/Rakefile +5 -5
- data/app/controllers/users/sessions_controller.rb +5 -0
- data/app/helpers/models_helper.rb +7 -0
- data/app/models/attachment.rb +3 -5
- data/app/models/collection.rb +12 -79
- data/app/models/component.rb +8 -67
- data/app/models/item.rb +8 -73
- data/app/models/target.rb +6 -5
- data/config/initializers/active_fedora_base.rb +11 -30
- data/config/initializers/{active_fedora_datastream.rb → active_fedora_file.rb} +1 -1
- data/config/initializers/devise.rb +2 -3
- data/config/initializers/subscriptions.rb +2 -19
- data/ddr-models.gemspec +10 -14
- data/lib/ddr/actions/fixity_check.rb +1 -1
- data/lib/ddr/actions/virus_check.rb +17 -10
- data/lib/ddr/auth.rb +6 -38
- data/lib/ddr/auth/ability.rb +1 -5
- data/lib/ddr/auth/ability_definitions/collection_ability_definitions.rb +0 -16
- data/lib/ddr/auth/ability_definitions/datastream_ability_definitions.rb +10 -4
- data/lib/ddr/auth/ability_definitions/role_based_ability_definitions.rb +16 -9
- data/lib/ddr/auth/ability_factory.rb +25 -2
- data/lib/ddr/auth/abstract_ability.rb +1 -2
- data/lib/ddr/auth/auth_context.rb +0 -18
- data/lib/ddr/auth/auth_context_factory.rb +2 -0
- data/lib/ddr/auth/group.rb +0 -6
- data/lib/ddr/auth/grouper_gateway.rb +0 -24
- data/lib/ddr/auth/permissions.rb +1 -12
- data/lib/ddr/auth/role_based_access_controls_enforcement.rb +5 -5
- data/lib/ddr/auth/roles.rb +1 -11
- data/lib/ddr/auth/roles/role_set.rb +0 -7
- data/lib/ddr/auth/roles/roles_datastream.rb +9 -0
- data/lib/ddr/contacts.rb +25 -0
- data/lib/ddr/datastreams.rb +10 -28
- data/lib/ddr/datastreams/datastream_behavior.rb +30 -100
- data/lib/ddr/datastreams/descriptive_metadata_datastream.rb +28 -31
- data/lib/ddr/datastreams/fits_datastream.rb +9 -22
- data/lib/ddr/datastreams/metadata_datastream.rb +17 -31
- data/lib/ddr/derivatives.rb +13 -16
- data/lib/ddr/derivatives/derivative.rb +68 -0
- data/lib/ddr/derivatives/{generator.rb → generators/generator.rb} +11 -7
- data/lib/ddr/derivatives/generators/png_generator.rb +23 -0
- data/lib/ddr/derivatives/generators/ptif_generator.rb +56 -0
- data/lib/ddr/derivatives/multires_image.rb +59 -0
- data/lib/ddr/derivatives/thumbnail.rb +36 -0
- data/lib/ddr/events.rb +0 -1
- data/lib/ddr/events/deletion_event.rb +9 -5
- data/lib/ddr/events/event.rb +8 -13
- data/lib/ddr/events/fixity_check_event.rb +0 -6
- data/lib/ddr/events/ingestion_event.rb +9 -5
- data/lib/ddr/events/update_event.rb +4 -17
- data/lib/ddr/index.rb +4 -4
- data/lib/ddr/index/abstract_query_result.rb +4 -3
- data/lib/ddr/index/connection.rb +9 -28
- data/lib/ddr/index/csv_query_result.rb +32 -47
- data/lib/ddr/index/field.rb +1 -11
- data/lib/ddr/index/fields.rb +16 -99
- data/lib/ddr/index/filter.rb +30 -103
- data/lib/ddr/index/filters.rb +19 -0
- data/lib/ddr/index/query.rb +11 -58
- data/lib/ddr/index/query_builder.rb +36 -147
- data/lib/ddr/index/query_clause.rb +19 -79
- data/lib/ddr/index/query_result.rb +4 -36
- data/lib/ddr/index/query_value.rb +18 -0
- data/lib/ddr/index/response.rb +2 -19
- data/lib/ddr/jobs.rb +12 -0
- data/lib/ddr/jobs/fits_file_characterization.rb +51 -0
- data/lib/ddr/jobs/permanent_id.rb +23 -0
- data/lib/ddr/managers.rb +1 -0
- data/lib/ddr/managers/derivatives_manager.rb +53 -93
- data/lib/ddr/managers/permanent_id_manager.rb +91 -0
- data/lib/ddr/managers/technical_metadata_manager.rb +10 -24
- data/lib/ddr/managers/workflow_manager.rb +10 -29
- data/lib/ddr/models.rb +50 -101
- data/lib/ddr/models/access_controllable.rb +12 -0
- data/lib/ddr/models/admin_set.rb +5 -16
- data/lib/ddr/models/base.rb +45 -165
- data/lib/ddr/models/describable.rb +19 -21
- data/lib/ddr/models/engine.rb +11 -39
- data/lib/ddr/models/error.rb +0 -3
- data/lib/ddr/models/file_management.rb +36 -72
- data/lib/ddr/models/finding_aid.rb +2 -35
- data/lib/ddr/models/fixity_checkable.rb +4 -0
- data/lib/ddr/models/governable.rb +3 -1
- data/lib/ddr/models/has_admin_metadata.rb +82 -56
- data/lib/ddr/models/has_attachments.rb +3 -1
- data/lib/ddr/models/has_children.rb +3 -7
- data/lib/ddr/models/has_content.rb +35 -32
- data/lib/ddr/models/has_multires_image.rb +7 -12
- data/lib/ddr/models/has_struct_metadata.rb +44 -6
- data/lib/ddr/models/has_thumbnail.rb +1 -4
- data/lib/ddr/models/indexing.rb +97 -186
- data/lib/ddr/models/licenses/admin_policy_license.rb +11 -0
- data/lib/ddr/models/licenses/effective_license.rb +9 -0
- data/lib/ddr/models/licenses/inherited_license.rb +9 -0
- data/lib/ddr/models/licenses/license.rb +21 -0
- data/lib/ddr/models/licenses/parent_license.rb +11 -0
- data/lib/ddr/models/metadata/descriptive_metadata.rb +50 -0
- data/lib/ddr/models/metadata/metadata.rb +37 -0
- data/lib/ddr/models/metadata/metadata_mapper.rb +32 -0
- data/lib/ddr/models/metadata/metadata_mappers.rb +18 -0
- data/lib/ddr/models/metadata/metadata_term.rb +24 -0
- data/lib/ddr/models/metadata/metadata_vocabularies.rb +18 -0
- data/lib/ddr/models/metadata/metadata_vocabulary.rb +34 -0
- data/lib/ddr/models/solr_document.rb +24 -156
- data/lib/ddr/models/struct_div.rb +63 -0
- data/lib/ddr/models/structure.rb +39 -175
- data/lib/ddr/models/version.rb +1 -1
- data/lib/ddr/models/year_facet.rb +118 -60
- data/lib/ddr/notifications.rb +12 -10
- data/lib/ddr/utils.rb +15 -28
- data/lib/ddr/vocab.rb +17 -15
- data/lib/ddr/vocab/asset.rb +17 -42
- data/lib/ddr/vocab/contact.rb +7 -5
- data/lib/ddr/vocab/display.rb +8 -6
- data/lib/ddr/vocab/duke_terms.rb +10 -8
- data/lib/ddr/vocab/rdf_vocabulary_parser.rb +39 -37
- data/lib/ddr/vocab/roles.rb +19 -17
- data/lib/ddr/vocab/sources/duketerms.rdf +8 -22
- data/lib/ddr/vocab/vocabulary.rb +26 -26
- data/spec/auth/ability_factory_spec.rb +1 -18
- data/spec/auth/ability_spec.rb +15 -119
- data/spec/auth/effective_permissions_spec.rb +1 -1
- data/spec/auth/effective_roles_spec.rb +1 -1
- data/spec/auth/ldap_gateway_spec.rb +9 -0
- data/spec/contacts/contacts_spec.rb +26 -0
- data/spec/controllers/including_role_based_access_controls_enforcement_spec.rb +5 -5
- data/spec/derivatives/multires_image_spec.rb +48 -0
- data/spec/derivatives/png_generator_spec.rb +8 -13
- data/spec/derivatives/ptif_generator_spec.rb +11 -9
- data/spec/derivatives/thumbnail_spec.rb +48 -0
- data/spec/dummy/config/environments/test.rb +1 -1
- data/spec/dummy/db/schema.rb +23 -25
- data/spec/factories/attachment_factories.rb +2 -2
- data/spec/factories/collection_factories.rb +2 -3
- data/spec/factories/component_factories.rb +2 -2
- data/spec/factories/item_factories.rb +2 -2
- data/spec/factories/structure_factories.rb +2 -8
- data/spec/factories/test_model_factories.rb +12 -4
- data/spec/fixtures/fits/document.xml +44 -42
- data/spec/fixtures/fits/image.xml +41 -42
- data/spec/helpers/models_helper_spec.rb +11 -0
- data/spec/index/filter_spec.rb +30 -208
- data/spec/index/filters_spec.rb +17 -0
- data/spec/index/query_spec.rb +10 -82
- data/spec/jobs/fits_file_characterization_spec.rb +52 -0
- data/spec/managers/derivatives_manager_spec.rb +105 -107
- data/spec/managers/technical_metadata_manager_spec.rb +27 -34
- data/spec/models/active_fedora_base_spec.rb +105 -5
- data/spec/models/active_fedora_datastream_spec.rb +39 -106
- data/spec/models/admin_set_spec.rb +10 -43
- data/spec/models/attachment_spec.rb +2 -3
- data/spec/models/collection_spec.rb +11 -225
- data/spec/models/component_spec.rb +4 -106
- data/spec/models/descriptive_metadata_spec.rb +38 -0
- data/spec/models/effective_license_spec.rb +64 -0
- data/spec/models/events_spec.rb +59 -52
- data/spec/models/file_management_spec.rb +13 -113
- data/spec/models/finding_aid_spec.rb +8 -31
- data/spec/models/has_admin_metadata_spec.rb +122 -131
- data/spec/models/has_children_spec.rb +3 -3
- data/spec/models/has_struct_metadata_spec.rb +37 -50
- data/spec/models/indexing_spec.rb +23 -160
- data/spec/models/item_spec.rb +2 -133
- data/spec/models/license_spec.rb +24 -0
- data/spec/models/solr_document_spec.rb +47 -236
- data/spec/models/struct_div_spec.rb +70 -0
- data/spec/models/structure_spec.rb +11 -89
- data/spec/models/target_spec.rb +2 -4
- data/spec/models/year_facet_spec.rb +23 -50
- data/spec/spec_helper.rb +13 -17
- data/spec/support/ezid_mock_identifier.rb +2 -2
- data/spec/support/shared_examples_for_auth_contexts.rb +0 -33
- data/spec/support/shared_examples_for_ddr_models.rb +94 -142
- data/spec/support/shared_examples_for_describables.rb +36 -31
- data/spec/support/shared_examples_for_governables.rb +2 -3
- data/spec/support/shared_examples_for_has_content.rb +46 -101
- data/spec/support/shared_examples_for_indexing.rb +6 -6
- data/spec/support/shared_examples_for_non_collection_models.rb +1 -32
- data/spec/support/structural_metadata_helper.rb +59 -230
- data/spec/utils_spec.rb +2 -0
- metadata +96 -229
- data/.ruby-version +0 -1
- data/config/initializers/rsolr_monkey_patches.rb +0 -7
- data/config/initializers/rubydora_monkey_patch.rb +0 -11
- data/config/locales/ddr-models.en.yml +0 -81
- data/db/migrate/20161021201011_add_permanent_id_to_events.rb +0 -8
- data/lib/ddr/auth/ability_definitions/admin_set_ability_definitions.rb +0 -9
- data/lib/ddr/auth/ability_definitions/lock_ability_definitions.rb +0 -13
- data/lib/ddr/auth/ability_definitions/publication_ability_definitions.rb +0 -16
- data/lib/ddr/datastreams/administrative_metadata_datastream.rb +0 -75
- data/lib/ddr/datastreams/caption_datastream.rb +0 -5
- data/lib/ddr/datastreams/content_datastream.rb +0 -17
- data/lib/ddr/datastreams/delete_external_files.rb +0 -29
- data/lib/ddr/datastreams/external_file_datastream.rb +0 -80
- data/lib/ddr/datastreams/intermediate_file_datastream.rb +0 -5
- data/lib/ddr/datastreams/multires_image_datastream.rb +0 -5
- data/lib/ddr/datastreams/streamable_media_datastream.rb +0 -5
- data/lib/ddr/derivatives/png_generator.rb +0 -17
- data/lib/ddr/derivatives/ptif_generator.rb +0 -55
- data/lib/ddr/derivatives/update_derivatives.rb +0 -25
- data/lib/ddr/events/deaccession_event.rb +0 -8
- data/lib/ddr/index/field_attribute.rb +0 -22
- data/lib/ddr/index/query_params.rb +0 -40
- data/lib/ddr/index/sort_order.rb +0 -28
- data/lib/ddr/models/cache.rb +0 -20
- data/lib/ddr/models/captionable.rb +0 -37
- data/lib/ddr/models/contact.rb +0 -23
- data/lib/ddr/models/file_characterization.rb +0 -37
- data/lib/ddr/models/has_intermediate_file.rb +0 -41
- data/lib/ddr/models/language.rb +0 -31
- data/lib/ddr/models/media_type.rb +0 -22
- data/lib/ddr/models/permanent_id.rb +0 -240
- data/lib/ddr/models/rights_statement.rb +0 -25
- data/lib/ddr/models/streamable.rb +0 -37
- data/lib/ddr/models/structures/agent.rb +0 -49
- data/lib/ddr/models/structures/component_type_term.rb +0 -29
- data/lib/ddr/models/structures/div.rb +0 -64
- data/lib/ddr/models/structures/f_locat.rb +0 -54
- data/lib/ddr/models/structures/file.rb +0 -52
- data/lib/ddr/models/structures/file_grp.rb +0 -35
- data/lib/ddr/models/structures/file_sec.rb +0 -22
- data/lib/ddr/models/structures/fptr.rb +0 -31
- data/lib/ddr/models/structures/mets_hdr.rb +0 -37
- data/lib/ddr/models/structures/mptr.rb +0 -49
- data/lib/ddr/models/structures/struct_map.rb +0 -40
- data/lib/ddr/models/with_content_file.rb +0 -37
- data/spec/datastreams/external_file_datastream_spec.rb +0 -48
- data/spec/dummy/config/structure_component_type.yml +0 -18
- data/spec/fixtures/abcd1234.vtt +0 -38
- data/spec/fixtures/arrow1rightred_e0.gif +0 -0
- data/spec/fixtures/extractedText1.txt +0 -1
- data/spec/fixtures/extractedText2.txt +0 -1
- data/spec/fixtures/extractedText3.txt +0 -3
- data/spec/fixtures/imageA.jpg +0 -0
- data/spec/fixtures/imageB.jpg +0 -0
- data/spec/index/csv_query_result_spec.rb +0 -44
- data/spec/index/fields_spec.rb +0 -380
- data/spec/index/query_builder_spec.rb +0 -140
- data/spec/index/query_clause_spec.rb +0 -68
- data/spec/models/cache_spec.rb +0 -32
- data/spec/models/contact_spec.rb +0 -56
- data/spec/models/descriptive_metadata_datastream_spec.rb +0 -139
- data/spec/models/file_characterization_spec.rb +0 -39
- data/spec/models/language_spec.rb +0 -59
- data/spec/models/media_type_spec.rb +0 -46
- data/spec/models/permanent_id_spec.rb +0 -432
- data/spec/models/rights_statement_spec.rb +0 -55
- data/spec/models/structures/agent_spec.rb +0 -30
- data/spec/models/structures/component_type_term_spec.rb +0 -14
- data/spec/models/structures/div_spec.rb +0 -26
- data/spec/models/structures/f_locat_spec.rb +0 -78
- data/spec/models/structures/file_grp_spec.rb +0 -23
- data/spec/models/structures/file_sec_spec.rb +0 -22
- data/spec/models/structures/file_spec.rb +0 -60
- data/spec/models/structures/fptr_spec.rb +0 -23
- data/spec/models/structures/mets_hdr_spec.rb +0 -26
- data/spec/models/structures/mptr_spec.rb +0 -25
- data/spec/models/structures/struct_map_spec.rb +0 -24
- data/spec/models/with_content_file_spec.rb +0 -37
- data/spec/support/shared_examples_for_associations.rb +0 -8
- data/spec/support/shared_examples_for_captionable.rb +0 -23
- data/spec/support/shared_examples_for_has_intermediate_file.rb +0 -28
- data/spec/support/shared_examples_for_publication.rb +0 -43
- data/spec/support/shared_examples_for_streamable_media.rb +0 -23
@@ -218,15 +218,14 @@ Devise.setup do |config|
|
|
218
218
|
# Explicit require is needed here for devise to find strategy
|
219
219
|
require "omniauth-shibboleth"
|
220
220
|
config.omniauth :shibboleth, {
|
221
|
-
uid_field:
|
221
|
+
uid_field: "eppn",
|
222
222
|
name_field: "displayName",
|
223
223
|
info_fields: {
|
224
224
|
email: "mail",
|
225
225
|
first_name: "givenName",
|
226
226
|
last_name: "sn",
|
227
227
|
nickname: "eduPersonNickname"
|
228
|
-
}
|
229
|
-
extra_fields: ["duDukeID"],
|
228
|
+
}
|
230
229
|
}
|
231
230
|
|
232
231
|
# ==> Warden configuration
|
@@ -8,28 +8,11 @@ ActiveSupport::Notifications.subscribe(Ddr::Notifications::FIXITY_CHECK, Ddr::Ev
|
|
8
8
|
# Virus Checks
|
9
9
|
ActiveSupport::Notifications.subscribe(Ddr::Notifications::VIRUS_CHECK, Ddr::Events::VirusCheckEvent)
|
10
10
|
|
11
|
-
#
|
11
|
+
# Creation
|
12
12
|
ActiveSupport::Notifications.subscribe(Ddr::Notifications::CREATION, Ddr::Events::CreationEvent)
|
13
|
-
ActiveSupport::Notifications.subscribe(Ddr::Models::Base::INGEST, Ddr::Events::IngestionEvent)
|
14
|
-
ActiveSupport::Notifications.subscribe(Ddr::Models::Base::INGEST, Ddr::Derivatives::UpdateDerivatives)
|
15
13
|
|
16
14
|
# Update
|
17
15
|
ActiveSupport::Notifications.subscribe(Ddr::Notifications::UPDATE, Ddr::Events::UpdateEvent)
|
18
|
-
ActiveSupport::Notifications.subscribe(Ddr::Models::Base::UPDATE, Ddr::Events::UpdateEvent)
|
19
|
-
ActiveSupport::Notifications.subscribe(Ddr::Models::Base::UPDATE, Ddr::Models::PermanentId)
|
20
|
-
ActiveSupport::Notifications.subscribe(Ddr::Models::Base::UPDATE, Ddr::Derivatives::UpdateDerivatives)
|
21
16
|
|
22
|
-
#
|
17
|
+
# Deletion
|
23
18
|
ActiveSupport::Notifications.subscribe(Ddr::Notifications::DELETION, Ddr::Events::DeletionEvent)
|
24
|
-
ActiveSupport::Notifications.subscribe(Ddr::Models::Base::DELETE, Ddr::Models::PermanentId)
|
25
|
-
ActiveSupport::Notifications.subscribe(Ddr::Models::Base::DELETE, Ddr::Events::DeletionEvent)
|
26
|
-
ActiveSupport::Notifications.subscribe(Ddr::Models::Base::DELETE, Ddr::Datastreams::DeleteExternalFiles)
|
27
|
-
|
28
|
-
# Deaccession
|
29
|
-
ActiveSupport::Notifications.subscribe(Ddr::Models::Base::DEACCESSION, Ddr::Models::PermanentId)
|
30
|
-
ActiveSupport::Notifications.subscribe(Ddr::Models::Base::DEACCESSION, Ddr::Events::DeaccessionEvent)
|
31
|
-
ActiveSupport::Notifications.subscribe(Ddr::Models::Base::DEACCESSION, Ddr::Datastreams::DeleteExternalFiles)
|
32
|
-
|
33
|
-
# Files
|
34
|
-
ActiveSupport::Notifications.subscribe(Ddr::Datastreams::DELETE, Ddr::Derivatives::UpdateDerivatives)
|
35
|
-
ActiveSupport::Notifications.subscribe(Ddr::Datastreams::DELETE, Ddr::Datastreams::DeleteExternalFiles)
|
data/ddr-models.gemspec
CHANGED
@@ -18,32 +18,28 @@ Gem::Specification.new do |s|
|
|
18
18
|
|
19
19
|
s.require_paths = ["lib", "app/models"]
|
20
20
|
|
21
|
-
s.add_dependency "rails", "
|
22
|
-
s.add_dependency "
|
23
|
-
s.add_dependency "active-fedora", "
|
24
|
-
s.add_dependency "
|
25
|
-
s.add_dependency "hydra-core", "~> 7.2"
|
21
|
+
s.add_dependency "rails", "~> 4.1.13"
|
22
|
+
s.add_dependency "active-triples", "~> 0.7.2"
|
23
|
+
s.add_dependency "active-fedora", "~> 9.5"
|
24
|
+
s.add_dependency "hydra-core", "~> 9.3"
|
26
25
|
s.add_dependency "hydra-validations", "~> 0.5"
|
27
26
|
s.add_dependency "devise", "~> 3.4"
|
28
27
|
s.add_dependency "omniauth-shibboleth", "~> 1.2.0"
|
29
28
|
s.add_dependency "grouper-rest-client"
|
30
|
-
s.add_dependency "ezid-client", "~> 1.
|
29
|
+
s.add_dependency "ezid-client", "~> 1.1", ">= 1.1.1"
|
31
30
|
s.add_dependency "resque", "~> 1.25"
|
32
31
|
s.add_dependency "rdf-vocab", "~> 0.8"
|
33
|
-
s.add_dependency "net-ldap", "~> 0.
|
32
|
+
s.add_dependency "net-ldap", "~> 0.11"
|
34
33
|
s.add_dependency "cancancan", "~> 1.12"
|
35
|
-
s.add_dependency "ddr-
|
36
|
-
s.add_dependency "
|
37
|
-
s.add_dependency "hashie", "~> 3.4", "< 3.4.4"
|
38
|
-
s.add_dependency "edtf", "~> 3.0"
|
34
|
+
s.add_dependency "ddr-aux-client", "~> 1.2", ">= 1.2.2"
|
35
|
+
s.add_dependency "ddr-antivirus", "2.0.0"
|
39
36
|
|
40
|
-
s.add_development_dependency "bundler", "~> 1.
|
37
|
+
s.add_development_dependency "bundler", "~> 1.10"
|
41
38
|
s.add_development_dependency "rake"
|
42
39
|
s.add_development_dependency "sqlite3"
|
43
40
|
s.add_development_dependency "rspec-rails", "~> 3.1"
|
44
41
|
s.add_development_dependency "rspec-its"
|
45
42
|
s.add_development_dependency "factory_girl_rails", "~> 4.4"
|
46
|
-
s.add_development_dependency "jettywrapper", "~>
|
43
|
+
s.add_development_dependency "jettywrapper", "~> 2.0"
|
47
44
|
s.add_development_dependency "database_cleaner"
|
48
|
-
s.add_development_dependency "byebug"
|
49
45
|
end
|
@@ -12,7 +12,7 @@ module Ddr
|
|
12
12
|
# Return result of fixity check
|
13
13
|
def self._execute(object)
|
14
14
|
Result.new(pid: object.pid).tap do |r|
|
15
|
-
object.
|
15
|
+
object.datastreams_to_validate.each do |dsid, ds|
|
16
16
|
r.success &&= ds.dsChecksumValid
|
17
17
|
r.results[dsid] = ds.profile
|
18
18
|
end
|
@@ -1,20 +1,27 @@
|
|
1
|
+
require "open3"
|
2
|
+
require "ostruct"
|
3
|
+
require "shellwords"
|
4
|
+
|
1
5
|
module Ddr::Actions
|
2
6
|
class VirusCheck
|
3
7
|
|
4
8
|
# @return [Hash] result data
|
5
9
|
# @raises [Ddr::Antivirus::VirusFoundError]
|
6
10
|
def self.call(file_path)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
result[:
|
15
|
-
|
16
|
-
result[:detail] = scan_result.output
|
11
|
+
unless File.exist?(file_path)
|
12
|
+
raise Error, "File not found: #{file_path}"
|
13
|
+
end
|
14
|
+
result = {}
|
15
|
+
begin
|
16
|
+
scan_result = Ddr::Antivirus.scan(file_path)
|
17
|
+
rescue Ddr::Antivirus::ScannerError => e
|
18
|
+
result[:exception] = [e.class.name, e.to_s]
|
19
|
+
scan_result = e.result
|
17
20
|
end
|
21
|
+
result[:event_date_time] = scan_result.scanned_at
|
22
|
+
result[:software] = scan_result.version
|
23
|
+
result[:detail] = scan_result.output
|
24
|
+
result
|
18
25
|
end
|
19
26
|
|
20
27
|
end
|
data/lib/ddr/auth.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
module Ddr
|
2
2
|
module Auth
|
3
3
|
extend ActiveSupport::Autoload
|
4
|
-
extend Deprecation
|
5
4
|
|
6
5
|
autoload :Ability
|
7
6
|
autoload :AbilityDefinitions
|
@@ -32,7 +31,6 @@ module Ddr
|
|
32
31
|
autoload :WebAuthContext
|
33
32
|
|
34
33
|
autoload_under 'ability_definitions' do
|
35
|
-
autoload :AdminSetAbilityDefinitions
|
36
34
|
autoload :AliasAbilityDefinitions
|
37
35
|
autoload :AttachmentAbilityDefinitions
|
38
36
|
autoload :CollectionAbilityDefinitions
|
@@ -40,8 +38,6 @@ module Ddr
|
|
40
38
|
autoload :DatastreamAbilityDefinitions
|
41
39
|
autoload :EventAbilityDefinitions
|
42
40
|
autoload :ItemAbilityDefinitions
|
43
|
-
autoload :PublicationAbilityDefinitions
|
44
|
-
autoload :LockAbilityDefinitions
|
45
41
|
autoload :RoleBasedAbilityDefinitions
|
46
42
|
autoload :SuperuserAbilityDefinitions
|
47
43
|
end
|
@@ -52,40 +48,15 @@ module Ddr
|
|
52
48
|
# Name of group whose members are authorized to create Collections
|
53
49
|
mattr_accessor :collection_creators_group
|
54
50
|
|
55
|
-
# Name of group whose members are authorized to act as a metadata manager
|
56
|
-
mattr_accessor :metadata_managers_group
|
57
|
-
|
58
|
-
# Group of which everyone (including anonymous users) is a member
|
59
|
-
def self.everyone_group
|
60
|
-
Deprecation.warn(Ddr::Auth,
|
61
|
-
"`Ddr::Auth.everyone_group` is deprecated and will be removed in ddr-models 3.0." \
|
62
|
-
" Use `Ddr::Auth::Groups::PUBLIC` instead.")
|
63
|
-
Groups::PUBLIC
|
64
|
-
end
|
65
|
-
|
66
|
-
# Group of authenticated users
|
67
|
-
def self.authenticated_users_group
|
68
|
-
Deprecation.warn(Ddr::Auth,
|
69
|
-
"`Ddr::Auth.authenticated_users_group` is deprecated and will be removed in ddr-models 3.0." \
|
70
|
-
" Use `Ddr::Auth::Groups::REGISTERED` instead.")
|
71
|
-
Groups::REGISTERED
|
72
|
-
end
|
73
|
-
|
74
|
-
def self.const_missing(name)
|
75
|
-
if name == :Superuser
|
76
|
-
Deprecation.warn(Ddr::Auth,
|
77
|
-
"`Ddr::Auth::Superuser` is deprecated and will be removed in ddr-models 3.0." \
|
78
|
-
" Use `Ddr::Auth::SuperuserAbility` instead.")
|
79
|
-
return SuperuserAbility
|
80
|
-
end
|
81
|
-
super
|
82
|
-
end
|
83
|
-
|
84
51
|
# Whether to require Shibboleth authentication
|
85
52
|
mattr_accessor :require_shib_user_authn do
|
86
53
|
false
|
87
54
|
end
|
88
55
|
|
56
|
+
mattr_accessor :sso_logout_url do
|
57
|
+
"/Shibboleth.sso/Logout?return=https://shib.oit.duke.edu/cgi-bin/logout.pl"
|
58
|
+
end
|
59
|
+
|
89
60
|
# Grouper gateway implementation
|
90
61
|
mattr_accessor :grouper_gateway do
|
91
62
|
GrouperGateway
|
@@ -100,11 +71,8 @@ module Ddr
|
|
100
71
|
"::Ability"
|
101
72
|
end
|
102
73
|
|
103
|
-
|
104
|
-
|
105
|
-
return filter
|
106
|
-
end
|
107
|
-
raise Ddr::Models::Error, "The \"REPOSITORY_GROUP_FILTER\" environment variable is not set."
|
74
|
+
mattr_accessor :repository_group_filter do
|
75
|
+
ENV["REPOSITORY_GROUP_FILTER"]
|
108
76
|
end
|
109
77
|
|
110
78
|
end
|
data/lib/ddr/auth/ability.rb
CHANGED
@@ -9,11 +9,7 @@ module Ddr
|
|
9
9
|
AttachmentAbilityDefinitions,
|
10
10
|
RoleBasedAbilityDefinitions,
|
11
11
|
DatastreamAbilityDefinitions,
|
12
|
-
EventAbilityDefinitions
|
13
|
-
PublicationAbilityDefinitions,
|
14
|
-
LockAbilityDefinitions,
|
15
|
-
AdminSetAbilityDefinitions,
|
16
|
-
]
|
12
|
+
EventAbilityDefinitions ]
|
17
13
|
|
18
14
|
end
|
19
15
|
end
|
@@ -6,22 +6,6 @@ module Ddr
|
|
6
6
|
if member_of? Ddr::Auth.collection_creators_group
|
7
7
|
can :create, ::Collection
|
8
8
|
end
|
9
|
-
can :export, ::Collection do |obj|
|
10
|
-
has_policy_permission?(obj, Permissions::READ)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
def policy_permissions(obj)
|
17
|
-
obj.roles
|
18
|
-
.in_policy_scope
|
19
|
-
.agent(agents)
|
20
|
-
.permissions
|
21
|
-
end
|
22
|
-
|
23
|
-
def has_policy_permission?(obj, perm)
|
24
|
-
policy_permissions(obj).include?(perm)
|
25
9
|
end
|
26
10
|
|
27
11
|
end
|
@@ -9,22 +9,28 @@ module Ddr
|
|
9
9
|
# course by the :manage ability.
|
10
10
|
DATASTREAM_DOWNLOAD_ABILITIES = {
|
11
11
|
Ddr::Datastreams::CONTENT => :download,
|
12
|
-
Ddr::Datastreams::DESC_METADATA => :read,
|
13
12
|
Ddr::Datastreams::EXTRACTED_TEXT => :download,
|
14
13
|
Ddr::Datastreams::FITS => :read,
|
15
|
-
Ddr::Datastreams::MULTIRES_IMAGE => :read,
|
16
14
|
Ddr::Datastreams::STRUCT_METADATA => :read,
|
17
15
|
Ddr::Datastreams::THUMBNAIL => :read,
|
18
16
|
}.freeze
|
19
17
|
|
20
18
|
def call
|
21
|
-
can :download, ActiveFedora::
|
22
|
-
can_download_datastream?(
|
19
|
+
can :download, ActiveFedora::File do |file|
|
20
|
+
can_download_datastream?(_dsid(file), _pid(file))
|
23
21
|
end
|
24
22
|
end
|
25
23
|
|
26
24
|
private
|
27
25
|
|
26
|
+
def _dsid(file)
|
27
|
+
File.basename(file.id)
|
28
|
+
end
|
29
|
+
|
30
|
+
def _pid(file)
|
31
|
+
File.dirname(file.id)
|
32
|
+
end
|
33
|
+
|
28
34
|
def can_download_datastream?(dsid, pid)
|
29
35
|
can? DATASTREAM_DOWNLOAD_ABILITIES.fetch(dsid), pid
|
30
36
|
rescue KeyError
|
@@ -12,20 +12,19 @@ module Ddr
|
|
12
12
|
|
13
13
|
private
|
14
14
|
|
15
|
-
def has_permission?(permission,
|
16
|
-
permissions(
|
15
|
+
def has_permission?(permission, obj)
|
16
|
+
permissions(obj).include? permission
|
17
17
|
end
|
18
18
|
|
19
|
-
def permissions(
|
20
|
-
case
|
19
|
+
def permissions(obj)
|
20
|
+
case obj
|
21
21
|
when Ddr::Models::Base, SolrDocument
|
22
|
-
cached_permissions
|
23
|
-
|
22
|
+
cached_permissions obj.pid do
|
23
|
+
obj.effective_permissions(agents)
|
24
24
|
end
|
25
25
|
when String
|
26
|
-
cached_permissions
|
27
|
-
|
28
|
-
doc.effective_permissions(agents)
|
26
|
+
cached_permissions obj do
|
27
|
+
permissions_doc(obj).effective_permissions(agents)
|
29
28
|
end
|
30
29
|
end
|
31
30
|
end
|
@@ -34,6 +33,14 @@ module Ddr
|
|
34
33
|
cache[pid] ||= block.call
|
35
34
|
end
|
36
35
|
|
36
|
+
def permissions_doc(pid)
|
37
|
+
roles_query_result = ActiveFedora::SolrService.query("id:\"#{pid}\"", rows: 1).first
|
38
|
+
if roles_query_result.nil?
|
39
|
+
raise "Solr document not found for PID \"#{pid}\"."
|
40
|
+
end
|
41
|
+
SolrDocument.new roles_query_result
|
42
|
+
end
|
43
|
+
|
37
44
|
end
|
38
45
|
end
|
39
46
|
end
|
@@ -1,9 +1,32 @@
|
|
1
1
|
module Ddr::Auth
|
2
2
|
class AbilityFactory
|
3
3
|
|
4
|
+
private_class_method :new
|
5
|
+
|
4
6
|
def self.call(user = nil, env = nil)
|
5
|
-
|
6
|
-
|
7
|
+
new(user, env).call
|
8
|
+
end
|
9
|
+
|
10
|
+
attr_reader :auth_context
|
11
|
+
|
12
|
+
delegate :anonymous?, :superuser?, to: :auth_context
|
13
|
+
|
14
|
+
def initialize(user, env)
|
15
|
+
@auth_context = AuthContextFactory.call(user, env)
|
16
|
+
end
|
17
|
+
|
18
|
+
def call
|
19
|
+
if anonymous?
|
20
|
+
AnonymousAbility.new(auth_context)
|
21
|
+
elsif superuser?
|
22
|
+
SuperuserAbility.new(auth_context)
|
23
|
+
else
|
24
|
+
default_ability.new(auth_context)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def default_ability
|
29
|
+
Ddr::Auth::default_ability.constantize
|
7
30
|
end
|
8
31
|
|
9
32
|
end
|
@@ -17,8 +17,7 @@ module Ddr::Auth
|
|
17
17
|
|
18
18
|
attr_reader :auth_context
|
19
19
|
|
20
|
-
delegate :anonymous?, :authenticated?, :
|
21
|
-
:user, :groups, :agents, :member_of?,
|
20
|
+
delegate :anonymous?, :authenticated?, :user, :groups, :agents, :member_of?,
|
22
21
|
:authorized_to_act_as_superuser?,
|
23
22
|
to: :auth_context
|
24
23
|
|
@@ -9,20 +9,6 @@ module Ddr::Auth
|
|
9
9
|
@env = env
|
10
10
|
end
|
11
11
|
|
12
|
-
def ability
|
13
|
-
if anonymous?
|
14
|
-
AnonymousAbility.new(self)
|
15
|
-
elsif superuser?
|
16
|
-
SuperuserAbility.new(self)
|
17
|
-
else
|
18
|
-
default_ability_class.new(self)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def default_ability_class
|
23
|
-
Ddr::Auth::default_ability.constantize
|
24
|
-
end
|
25
|
-
|
26
12
|
# Return whether a user is absent from the auth context.
|
27
13
|
# @return [Boolean]
|
28
14
|
def anonymous?
|
@@ -41,10 +27,6 @@ module Ddr::Auth
|
|
41
27
|
env && env.key?("warden") && env["warden"].authenticate?(scope: :superuser)
|
42
28
|
end
|
43
29
|
|
44
|
-
def metadata_manager?
|
45
|
-
member_of? Ddr::Auth.metadata_managers_group
|
46
|
-
end
|
47
|
-
|
48
30
|
# Return the user agent for this context.
|
49
31
|
# @return [String] or nil, if auth context is anonymous/
|
50
32
|
def agent
|
data/lib/ddr/auth/group.rb
CHANGED
@@ -4,7 +4,6 @@ module Ddr
|
|
4
4
|
module Auth
|
5
5
|
# Wraps a String
|
6
6
|
class Group < SimpleDelegator
|
7
|
-
extend Deprecation
|
8
7
|
|
9
8
|
attr_reader :rule
|
10
9
|
|
@@ -32,11 +31,6 @@ module Ddr
|
|
32
31
|
to_s
|
33
32
|
end
|
34
33
|
|
35
|
-
def to_agent
|
36
|
-
Deprecation.warn(self.class, "`to_agent` is deprecated. Use `agent` instead.")
|
37
|
-
agent
|
38
|
-
end
|
39
|
-
|
40
34
|
def inspect
|
41
35
|
"#<#{self.class.name} id=#{id.inspect}, label=#{label.inspect}>"
|
42
36
|
end
|