ddr-models 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +12 -0
- data/README.md +5 -0
- data/Rakefile +37 -0
- data/app/models/attachment.rb +7 -0
- data/app/models/collection.rb +54 -0
- data/app/models/component.rb +15 -0
- data/app/models/item.rb +19 -0
- data/app/models/solr_document.rb +36 -0
- data/app/models/target.rb +8 -0
- data/config/initializers/active_fedora_base.rb +77 -0
- data/config/initializers/active_fedora_datastream.rb +5 -0
- data/config/initializers/ddr.rb +8 -0
- data/config/initializers/devise.rb +245 -0
- data/config/initializers/devise.rb~ +245 -0
- data/config/initializers/subscriptions.rb +15 -0
- data/config/routes.rb +2 -0
- data/db/migrate/20141021233359_create_events.rb +28 -0
- data/db/migrate/20141021234156_create_minted_ids.rb +19 -0
- data/db/migrate/20141103192146_create_workflow_state.rb +13 -0
- data/db/migrate/20141104181418_create_users.rb +34 -0
- data/db/migrate/20141104181418_create_users.rb~ +6 -0
- data/lib/ddr-models.rb +1 -0
- data/lib/ddr/actions.rb +8 -0
- data/lib/ddr/actions/fixity_check.rb +35 -0
- data/lib/ddr/auth.rb +45 -0
- data/lib/ddr/auth.rb~ +47 -0
- data/lib/ddr/auth/ability.rb +204 -0
- data/lib/ddr/auth/ability.rb~ +204 -0
- data/lib/ddr/auth/group_service.rb +53 -0
- data/lib/ddr/auth/group_service.rb~ +53 -0
- data/lib/ddr/auth/grouper_service.rb +76 -0
- data/lib/ddr/auth/grouper_service.rb~ +77 -0
- data/lib/ddr/auth/remote_group_service.rb +35 -0
- data/lib/ddr/auth/remote_group_service.rb~ +35 -0
- data/lib/ddr/auth/superuser.rb +13 -0
- data/lib/ddr/auth/superuser.rb~ +9 -0
- data/lib/ddr/auth/user.rb +71 -0
- data/lib/ddr/auth/user.rb~ +65 -0
- data/lib/ddr/configurable.rb +34 -0
- data/lib/ddr/datastreams.rb +32 -0
- data/lib/ddr/datastreams/content_metadata_datastream.rb +147 -0
- data/lib/ddr/datastreams/datastream_behavior.rb +95 -0
- data/lib/ddr/datastreams/descriptive_metadata_datastream.rb +84 -0
- data/lib/ddr/datastreams/properties_datastream.rb +25 -0
- data/lib/ddr/datastreams/role_assignments_datastream.rb +19 -0
- data/lib/ddr/events.rb +17 -0
- data/lib/ddr/events/creation_event.rb +12 -0
- data/lib/ddr/events/event.rb +163 -0
- data/lib/ddr/events/fixity_check_event.rb +43 -0
- data/lib/ddr/events/ingestion_event.rb +12 -0
- data/lib/ddr/events/preservation_event_behavior.rb +37 -0
- data/lib/ddr/events/preservation_event_type.rb +24 -0
- data/lib/ddr/events/reindex_object_after_save.rb +18 -0
- data/lib/ddr/events/update_event.rb +9 -0
- data/lib/ddr/events/validation_event.rb +11 -0
- data/lib/ddr/events/virus_check_event.rb +30 -0
- data/lib/ddr/index_fields.rb +39 -0
- data/lib/ddr/metadata.rb +22 -0
- data/lib/ddr/metadata/duke_terms.rb +15 -0
- data/lib/ddr/metadata/premis_event.rb +59 -0
- data/lib/ddr/metadata/rdf_vocabulary_parser.rb +45 -0
- data/lib/ddr/metadata/roles_vocabulary.rb +10 -0
- data/lib/ddr/metadata/sources/duketerms.rdf.xml +856 -0
- data/lib/ddr/metadata/vocabulary.rb +37 -0
- data/lib/ddr/models.rb +60 -0
- data/lib/ddr/models/access_controllable.rb +23 -0
- data/lib/ddr/models/base.rb +37 -0
- data/lib/ddr/models/describable.rb +81 -0
- data/lib/ddr/models/engine.rb +58 -0
- data/lib/ddr/models/error.rb +12 -0
- data/lib/ddr/models/event_loggable.rb +36 -0
- data/lib/ddr/models/file_management.rb +183 -0
- data/lib/ddr/models/fixity_checkable.rb +20 -0
- data/lib/ddr/models/governable.rb +48 -0
- data/lib/ddr/models/has_attachments.rb +12 -0
- data/lib/ddr/models/has_children.rb +21 -0
- data/lib/ddr/models/has_content.rb +114 -0
- data/lib/ddr/models/has_content_metadata.rb +16 -0
- data/lib/ddr/models/has_properties.rb +15 -0
- data/lib/ddr/models/has_role_assignments.rb +17 -0
- data/lib/ddr/models/has_thumbnail.rb +27 -0
- data/lib/ddr/models/has_workflow.rb +29 -0
- data/lib/ddr/models/indexing.rb +53 -0
- data/lib/ddr/models/licensable.rb +28 -0
- data/lib/ddr/models/minted_id.rb +10 -0
- data/lib/ddr/models/permanent_identification.rb +48 -0
- data/lib/ddr/models/solr_document.rb +193 -0
- data/lib/ddr/models/version.rb +5 -0
- data/lib/ddr/notifications.rb +15 -0
- data/lib/ddr/services.rb +8 -0
- data/lib/ddr/services/id_service.rb +48 -0
- data/lib/ddr/utils.rb +153 -0
- data/lib/ddr/workflow.rb +8 -0
- data/lib/ddr/workflow/workflow_state.rb +39 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/models/user.rb +5 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +29 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +78 -0
- data/spec/dummy/config/environments/test.rb +39 -0
- data/spec/dummy/config/initializers/assets.rb +8 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +56 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/schema.rb +80 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +4974 -0
- data/spec/dummy/log/test.log +55627 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/factories/attachment_factories.rb +15 -0
- data/spec/factories/collection_factories.rb +16 -0
- data/spec/factories/component_factories.rb +15 -0
- data/spec/factories/event_factories.rb +7 -0
- data/spec/factories/item_factories.rb +16 -0
- data/spec/factories/target_factories.rb +11 -0
- data/spec/factories/test_model_factories.rb +133 -0
- data/spec/factories/user_factories.rb +7 -0
- data/spec/factories/user_factories.rb~ +7 -0
- data/spec/features/grouper_integration_spec.rb~ +21 -0
- data/spec/fixtures/contentMetadata.xml +37 -0
- data/spec/fixtures/image1.tiff +0 -0
- data/spec/fixtures/image2.tiff +0 -0
- data/spec/fixtures/image3.tiff +0 -0
- data/spec/fixtures/library-devil.tiff +0 -0
- data/spec/fixtures/sample.docx +0 -0
- data/spec/fixtures/sample.pdf +0 -0
- data/spec/fixtures/target.png +0 -0
- data/spec/models/ability_spec.rb +248 -0
- data/spec/models/ability_spec.rb~ +245 -0
- data/spec/models/active_fedora_base_spec.rb +107 -0
- data/spec/models/active_fedora_datastream_spec.rb +121 -0
- data/spec/models/attachment_spec.rb +13 -0
- data/spec/models/collection_spec.rb +33 -0
- data/spec/models/component_spec.rb +8 -0
- data/spec/models/descriptive_metadata_datastream_spec.rb +102 -0
- data/spec/models/events_spec.rb +64 -0
- data/spec/models/file_management_spec.rb +179 -0
- data/spec/models/has_role_assignments_spec.rb +29 -0
- data/spec/models/has_workflow_spec.rb +54 -0
- data/spec/models/item_spec.rb +8 -0
- data/spec/models/permanent_identification_spec.rb +65 -0
- data/spec/models/role_assignments_datastream_spec.rb +25 -0
- data/spec/models/superuser_spec.rb +13 -0
- data/spec/models/superuser_spec.rb~ +13 -0
- data/spec/models/target_spec.rb +8 -0
- data/spec/models/user_spec.rb +60 -0
- data/spec/models/user_spec.rb~ +56 -0
- data/spec/services/group_service_spec.rb +75 -0
- data/spec/services/group_service_spec.rb~ +71 -0
- data/spec/services/id_service_spec.rb +33 -0
- data/spec/spec_helper.rb +125 -0
- data/spec/support/shared_examples_for_access_controllables.rb +6 -0
- data/spec/support/shared_examples_for_associations.rb +8 -0
- data/spec/support/shared_examples_for_ddr_models.rb +7 -0
- data/spec/support/shared_examples_for_describables.rb +63 -0
- data/spec/support/shared_examples_for_event_loggables.rb +3 -0
- data/spec/support/shared_examples_for_events.rb +179 -0
- data/spec/support/shared_examples_for_governables.rb +17 -0
- data/spec/support/shared_examples_for_has_content.rb +136 -0
- data/spec/support/shared_examples_for_has_content_metadata.rb +74 -0
- data/spec/support/shared_examples_for_has_properties.rb +5 -0
- data/spec/support/shared_examples_for_indexing.rb +36 -0
- metadata +562 -0
@@ -0,0 +1,245 @@
|
|
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
|
@@ -0,0 +1,15 @@
|
|
1
|
+
##
|
2
|
+
## Subscriptions to ActiveSupport::Notifications instrumentation events
|
3
|
+
##
|
4
|
+
|
5
|
+
# Fixity Checks
|
6
|
+
ActiveSupport::Notifications.subscribe(Ddr::Notifications::FIXITY_CHECK, Ddr::Events::FixityCheckEvent)
|
7
|
+
|
8
|
+
# Virus Checks
|
9
|
+
ActiveSupport::Notifications.subscribe(Ddr::Notifications::VIRUS_CHECK, Ddr::Events::VirusCheckEvent)
|
10
|
+
|
11
|
+
# Creation
|
12
|
+
ActiveSupport::Notifications.subscribe(Ddr::Notifications::CREATION, Ddr::Events::CreationEvent)
|
13
|
+
|
14
|
+
# Update
|
15
|
+
ActiveSupport::Notifications.subscribe(Ddr::Notifications::UPDATE, Ddr::Events::UpdateEvent)
|
data/config/routes.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
class CreateEvents < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
unless table_exists?("events")
|
4
|
+
create_table "events" do |t|
|
5
|
+
t.datetime "event_date_time"
|
6
|
+
t.integer "user_id"
|
7
|
+
t.string "type"
|
8
|
+
t.string "pid"
|
9
|
+
t.string "software"
|
10
|
+
t.text "comment"
|
11
|
+
t.datetime "created_at"
|
12
|
+
t.datetime "updated_at"
|
13
|
+
t.string "summary"
|
14
|
+
t.string "outcome"
|
15
|
+
t.text "detail"
|
16
|
+
end
|
17
|
+
|
18
|
+
add_index "events", ["event_date_time"], name: "index_events_on_event_date_time"
|
19
|
+
add_index "events", ["outcome"], name: "index_events_on_outcome"
|
20
|
+
add_index "events", ["pid"], name: "index_events_on_pid"
|
21
|
+
add_index "events", ["type"], name: "index_events_on_type"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def down
|
26
|
+
raise ActiveRecord::IrreversibleMigration
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class CreateMintedIds < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
unless table_exists?("minted_ids")
|
4
|
+
create_table "minted_ids" do |t|
|
5
|
+
t.string "minted_id"
|
6
|
+
t.string "referent"
|
7
|
+
t.datetime "created_at"
|
8
|
+
t.datetime "updated_at"
|
9
|
+
end
|
10
|
+
|
11
|
+
add_index "minted_ids", ["minted_id"], name: "index_minted_ids_on_minted_id", unique: true
|
12
|
+
add_index "minted_ids", ["referent"], name: "index_minted_ids_on_referent"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def down
|
17
|
+
raise ActiveRecord::IrreversibleMigration
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class CreateWorkflowState < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table "workflow_states" do |t|
|
4
|
+
t.string "pid"
|
5
|
+
t.string "workflow_state"
|
6
|
+
t.datetime "created_at"
|
7
|
+
t.datetime "updated_at"
|
8
|
+
end
|
9
|
+
|
10
|
+
add_index "workflow_states", ["pid"], name: "index_workflow_states_on_pid", unique: true
|
11
|
+
add_index "workflow_states", ["workflow_state"], name: "index_workflow_states_on_workflow_state"
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class CreateUsers < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
unless table_exists?("users")
|
4
|
+
create_table "users" do |t|
|
5
|
+
t.string "email", default: "", null: false
|
6
|
+
t.string "encrypted_password", default: "", null: false
|
7
|
+
t.string "reset_password_token"
|
8
|
+
t.datetime "reset_password_sent_at"
|
9
|
+
t.datetime "remember_created_at"
|
10
|
+
t.integer "sign_in_count", default: 0
|
11
|
+
t.datetime "current_sign_in_at"
|
12
|
+
t.datetime "last_sign_in_at"
|
13
|
+
t.string "current_sign_in_ip"
|
14
|
+
t.string "last_sign_in_ip"
|
15
|
+
t.datetime "created_at", null: false
|
16
|
+
t.datetime "updated_at", null: false
|
17
|
+
t.string "username", default: "", null: false
|
18
|
+
t.string "first_name"
|
19
|
+
t.string "middle_name"
|
20
|
+
t.string "nickname"
|
21
|
+
t.string "last_name"
|
22
|
+
t.string "display_name"
|
23
|
+
end
|
24
|
+
|
25
|
+
add_index "users", ["email"], name: "index_users_on_email"
|
26
|
+
add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
|
27
|
+
add_index "users", ["username"], name: "index_users_on_username", unique: true
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def down
|
32
|
+
raise ActiveRecord::IrreversibleMigration
|
33
|
+
end
|
34
|
+
end
|
data/lib/ddr-models.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'ddr/models'
|
data/lib/ddr/actions.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
module Ddr
|
2
|
+
module Actions
|
3
|
+
class FixityCheck
|
4
|
+
|
5
|
+
# Return result of fixity check - wrapped by a notifier
|
6
|
+
def self.execute(object)
|
7
|
+
ActiveSupport::Notifications.instrument(Ddr::Notifications::FIXITY_CHECK) do |payload|
|
8
|
+
payload[:result] = _execute(object)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
# Return result of fixity check
|
13
|
+
def self._execute(object)
|
14
|
+
Result.new(pid: object.pid).tap do |r|
|
15
|
+
object.datastreams_to_validate.each do |dsid, ds|
|
16
|
+
r.success &&= ds.dsChecksumValid
|
17
|
+
r.results[dsid] = ds.profile
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class Result
|
23
|
+
attr_accessor :pid, :success, :results, :checked_at
|
24
|
+
|
25
|
+
def initialize(args={})
|
26
|
+
@pid = args[:pid]
|
27
|
+
@success = args[:success] || true
|
28
|
+
@results = args[:results] || {}
|
29
|
+
@checked_at = args[:checked_at] || Time.now.utc
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/ddr/auth.rb
ADDED
@@ -0,0 +1,45 @@
|
|
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
|
14
|
+
|
15
|
+
## Remote groups (i.e., Grouper) config settings
|
16
|
+
# request.env key for group memberships
|
17
|
+
mattr_accessor :remote_groups_env_key do
|
18
|
+
"ismemberof"
|
19
|
+
end
|
20
|
+
|
21
|
+
# request.env value internal delimiter
|
22
|
+
mattr_accessor :remote_groups_env_value_delim do
|
23
|
+
";"
|
24
|
+
end
|
25
|
+
|
26
|
+
# pattern/repl for converting request.env membership values to proper (Grouper) group names
|
27
|
+
mattr_accessor :remote_groups_env_value_sub do
|
28
|
+
[/^urn:mace:duke\.edu:groups/, "duke"]
|
29
|
+
end
|
30
|
+
|
31
|
+
# Filter for getting list of remote groups for the repository - String, not Regexp
|
32
|
+
mattr_accessor :remote_groups_name_filter do
|
33
|
+
"duke:library:repository:ddr:"
|
34
|
+
end
|
35
|
+
|
36
|
+
mattr_accessor :everyone_group do
|
37
|
+
"public"
|
38
|
+
end
|
39
|
+
|
40
|
+
mattr_accessor :authenticated_users_group do
|
41
|
+
"registered"
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|