dina 0.9.6.0 → 1.0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dina/authentication/authentication.rb +19 -37
- data/lib/dina/casters/{object_caster.rb → hash_caster.rb} +3 -1
- data/lib/dina/models/assemblage.rb +1 -1
- data/lib/dina/models/material_sample/collecting_event.rb +2 -2
- data/lib/dina/models/material_sample/material_sample.rb +7 -7
- data/lib/dina/models/object_store/object_store.rb +1 -1
- data/lib/dina/models/storage/storage_unit_type.rb +1 -1
- data/lib/dina/models/transaction/transaction.rb +2 -2
- data/lib/dina/models/user.rb +1 -1
- data/lib/dina/version.rb +3 -3
- data/lib/dina.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19e690231bb618d0e35421466a61c550095d2f3bfe6ee83b258e03f8e6873f7d
|
4
|
+
data.tar.gz: 6733125d440e421b987e2c09bfb2d479d33d20f350f355033bb6bc9c22a104b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40e453289825aec7185c1c7bf7d316c4f75a13ffcf26f419b9f965aa2434154207da2a7d43dfcdc6d0ef08dac10cf2c6a931a36dcdbe348f73d87098d063217c
|
7
|
+
data.tar.gz: aef21cc4aed3d0670809fa0fec20488b9702d8abcf7b653c3d44e33f4d9f27448c3cc3712a04f4bb320bc5ecb882af71cbc751a8d3d1fc945c8d48c18d30825a
|
@@ -25,7 +25,6 @@ module Dina
|
|
25
25
|
# token_store_file: "file to store the token",
|
26
26
|
# user: "username provided by DINA admin in Keycloak",
|
27
27
|
# password: "password provided by DINA admin in Keycloak",
|
28
|
-
# server_name: "used locally to reference the token",
|
29
28
|
# client_id: "provided by DINA admin in Keycloak",
|
30
29
|
# endpoint_url: "DINA API URL without terminating slash",
|
31
30
|
# authorization_url: "Keycloak authorization URL without terminating slash".
|
@@ -37,7 +36,6 @@ module Dina
|
|
37
36
|
raise ConfigItemMissing, "Missing token_store_file from config." unless opts[:token_store_file]
|
38
37
|
raise ConfigItemMissing, "Missing user from config." unless opts[:user]
|
39
38
|
raise ConfigItemMissing, "Missing password from config." unless opts[:password]
|
40
|
-
raise ConfigItemMissing, "Missing server_name from config." unless opts[:server_name]
|
41
39
|
raise ConfigItemMissing, "Missing client_id from config." unless opts[:client_id]
|
42
40
|
raise ConfigItemMissing, "Missing endpoint_url from config." unless opts[:endpoint_url]
|
43
41
|
raise ConfigItemMissing, "Missing authorization_url from config." unless opts[:authorization_url]
|
@@ -53,17 +51,17 @@ module Dina
|
|
53
51
|
Keycloak.auth_server_url = config.authorization_url
|
54
52
|
Keycloak.realm = config.realm
|
55
53
|
|
56
|
-
if ::File.zero?(config.token_store_file)
|
57
|
-
|
54
|
+
if ::File.zero?(config.token_store_file)
|
55
|
+
save_token(hash: empty_token)
|
58
56
|
end
|
59
57
|
end
|
60
58
|
|
61
|
-
# Gets, sets, and renews a Bearer access token as required and produces a
|
59
|
+
# Gets, sets, and renews a Bearer access token as required and produces a Bearer string
|
62
60
|
#
|
63
61
|
# @return [String] the Bearer token
|
64
62
|
def header
|
65
63
|
if access_token.nil? || refresh_token.nil?
|
66
|
-
|
64
|
+
get_token
|
67
65
|
end
|
68
66
|
|
69
67
|
if Time.now >= Time.parse(auth_expiry)
|
@@ -75,7 +73,7 @@ module Dina
|
|
75
73
|
|
76
74
|
# Save default values in token store file
|
77
75
|
def flush
|
78
|
-
|
76
|
+
save_token(hash: empty_token)
|
79
77
|
end
|
80
78
|
|
81
79
|
def flush_config
|
@@ -91,7 +89,6 @@ module Dina
|
|
91
89
|
token_store_file: nil,
|
92
90
|
user: nil,
|
93
91
|
password: nil,
|
94
|
-
server_name: nil,
|
95
92
|
client_id: nil,
|
96
93
|
endpoint_url: nil,
|
97
94
|
realm: nil,
|
@@ -101,7 +98,7 @@ module Dina
|
|
101
98
|
|
102
99
|
def access_token
|
103
100
|
begin
|
104
|
-
token[
|
101
|
+
token[:access_token]
|
105
102
|
rescue
|
106
103
|
raise TokenStoreContentInvalid
|
107
104
|
end
|
@@ -109,7 +106,7 @@ module Dina
|
|
109
106
|
|
110
107
|
def refresh_token
|
111
108
|
begin
|
112
|
-
token[
|
109
|
+
token[:refresh_token]
|
113
110
|
rescue
|
114
111
|
raise TokenStoreContentInvalid
|
115
112
|
end
|
@@ -117,7 +114,7 @@ module Dina
|
|
117
114
|
|
118
115
|
def auth_expiry
|
119
116
|
begin
|
120
|
-
token[
|
117
|
+
token[:auth_expiry]
|
121
118
|
rescue
|
122
119
|
raise TokenStoreContentInvalid
|
123
120
|
end
|
@@ -129,13 +126,8 @@ module Dina
|
|
129
126
|
config.password,
|
130
127
|
client_id= config.client_id,
|
131
128
|
secret='')
|
132
|
-
JSON.parse(response, symbolize_names: true)
|
133
|
-
|
134
|
-
|
135
|
-
def set_token
|
136
|
-
json = get_token
|
137
|
-
auth_expiry = (Time.now + json[:expires_in].seconds).to_s
|
138
|
-
save_token(access_token: json[:access_token], refresh_token: json[:refresh_token], auth_expiry: auth_expiry)
|
129
|
+
json = JSON.parse(response, symbolize_names: true)
|
130
|
+
save_token(hash: json)
|
139
131
|
end
|
140
132
|
|
141
133
|
def renew_token
|
@@ -145,10 +137,9 @@ module Dina
|
|
145
137
|
client_id= config.client_id,
|
146
138
|
secret='')
|
147
139
|
json = JSON.parse(response, symbolize_names: true)
|
148
|
-
|
149
|
-
save_token(access_token: json[:access_token], refresh_token: json[:refresh_token], auth_expiry: auth_expiry)
|
140
|
+
save_token(hash: json)
|
150
141
|
rescue
|
151
|
-
|
142
|
+
get_token
|
152
143
|
end
|
153
144
|
end
|
154
145
|
|
@@ -157,28 +148,19 @@ module Dina
|
|
157
148
|
end
|
158
149
|
|
159
150
|
def empty_token
|
160
|
-
|
161
|
-
data[config.server_name.to_sym] = {
|
151
|
+
{
|
162
152
|
access_token: nil,
|
163
153
|
refresh_token: nil,
|
154
|
+
expires_in: nil,
|
164
155
|
auth_expiry: nil
|
165
156
|
}
|
166
|
-
data
|
167
|
-
end
|
168
|
-
|
169
|
-
def save_token(access_token:, refresh_token:, auth_expiry:)
|
170
|
-
data = JSON.parse(::File.read(config.token_store_file), symbolize_names: true) rescue {}
|
171
|
-
data[config.server_name.to_sym] = {
|
172
|
-
access_token: access_token,
|
173
|
-
refresh_token: refresh_token,
|
174
|
-
auth_expiry: auth_expiry
|
175
|
-
}
|
176
|
-
write_token(data: data)
|
177
157
|
end
|
178
158
|
|
179
|
-
def
|
180
|
-
|
181
|
-
|
159
|
+
def save_token(hash:)
|
160
|
+
auth_expiry = (Time.now + hash[:expires_in].seconds).to_s rescue nil
|
161
|
+
hash.merge!({ auth_expiry: auth_expiry })
|
162
|
+
::File.write(config.token_store_file, JSON.dump(hash))
|
163
|
+
@token = hash
|
182
164
|
end
|
183
165
|
|
184
166
|
end
|
@@ -7,7 +7,7 @@ module Dina
|
|
7
7
|
property :name, type: :string
|
8
8
|
property :multilingualTitle, type: :multilingual_title
|
9
9
|
property :multilingualDescription, type: :multilingual_description
|
10
|
-
property :managedAttributes, type: :
|
10
|
+
property :managedAttributes, type: :hash
|
11
11
|
property :createdBy, type: :string
|
12
12
|
property :createdOn, type: :time
|
13
13
|
|
@@ -35,8 +35,8 @@ module Dina
|
|
35
35
|
property :notPubliclyReleasableReason, type: :string, default: nil
|
36
36
|
property :tags, type: :array, default: []
|
37
37
|
property :geographicPlaceNameSource, type: :string
|
38
|
-
property :geographicPlaceNameSourceDetail, type: :
|
39
|
-
property :managedAttributes, type: :
|
38
|
+
property :geographicPlaceNameSourceDetail, type: :hash, default: {}
|
39
|
+
property :managedAttributes, type: :hash
|
40
40
|
property :geoReferenceAssertions, type: :array, default: []
|
41
41
|
property :eventGeom, type: :string
|
42
42
|
property :extensionValues, type: :array, default: []
|
@@ -11,8 +11,8 @@ module Dina
|
|
11
11
|
property :createdOn, type: :time
|
12
12
|
property :barcode, type: :string
|
13
13
|
property :group, type: :string
|
14
|
-
property :managedAttributes, type: :
|
15
|
-
property :preparationManagedAttributes, type: :
|
14
|
+
property :managedAttributes, type: :hash
|
15
|
+
property :preparationManagedAttributes, type: :hash
|
16
16
|
property :dwcOtherCatalogNumbers, type: :array
|
17
17
|
property :preservationType, type: :string
|
18
18
|
property :preparationFixative, type: :string
|
@@ -25,8 +25,8 @@ module Dina
|
|
25
25
|
property :stateChangedOn, type: :date
|
26
26
|
property :stateChangeRemarks, type: :string
|
27
27
|
property :materialSampleRemarks, type: :string
|
28
|
-
property :extensionValues, type: :
|
29
|
-
property :restrictionFieldsExtension, type: :
|
28
|
+
property :extensionValues, type: :hash
|
29
|
+
property :restrictionFieldsExtension, type: :hash
|
30
30
|
property :restrictionRemarks, type: :string
|
31
31
|
property :isRestricted, type: :boolean
|
32
32
|
property :materialSampleChildren, type: :array
|
@@ -34,9 +34,9 @@ module Dina
|
|
34
34
|
property :tags, type: :array, default: []
|
35
35
|
property :publiclyReleasable, type: :boolean, default: true
|
36
36
|
property :notPubliclyReleasableReason, type: :string
|
37
|
-
property :hostOrganism, type: :
|
38
|
-
property :scheduledActions, type: :
|
39
|
-
property :hierarchy, type: :
|
37
|
+
property :hostOrganism, type: :hash, default: { name: nil, remarks: nil }
|
38
|
+
property :scheduledActions, type: :hash
|
39
|
+
property :hierarchy, type: :hash
|
40
40
|
property :allowDuplicateName, type: :boolean
|
41
41
|
|
42
42
|
has_one :collection, class_name: "Collection"
|
@@ -24,7 +24,7 @@ module Dina
|
|
24
24
|
property :xmpRightsOwner, type: :string, default: "Government of Canada"
|
25
25
|
property :publiclyReleasable, type: :boolean, default: true
|
26
26
|
property :notPubliclyReleasableReason, type: :string
|
27
|
-
property :managedAttributes, type: :
|
27
|
+
property :managedAttributes, type: :hash
|
28
28
|
property :acTags, type: :string
|
29
29
|
property :orientation, type: :integer
|
30
30
|
property :resourceExternalURL, type: :string
|
@@ -6,7 +6,7 @@ module Dina
|
|
6
6
|
property :group, type: :string
|
7
7
|
property :name, type: :string
|
8
8
|
property :isInseperable, type: :boolean
|
9
|
-
property :gridLayoutDefinition, type: :
|
9
|
+
property :gridLayoutDefinition, type: :hash
|
10
10
|
property :createdBy, type: :string
|
11
11
|
property :createdOn, type: :time
|
12
12
|
|
@@ -15,9 +15,9 @@ module Dina
|
|
15
15
|
property :closedDate, type: :date
|
16
16
|
property :dueDate, type: :date
|
17
17
|
property :remarks, type: :string
|
18
|
-
property :managedAttributes, type: :
|
18
|
+
property :managedAttributes, type: :hash
|
19
19
|
property :agentRoles, type: :array # Each of type Dina::AgentRole
|
20
|
-
property :shipment, type: :
|
20
|
+
property :shipment, type: :hash # Of type Dina::Shipment
|
21
21
|
property :createdBy, type: :string
|
22
22
|
property :createdOn, type: :time
|
23
23
|
|
data/lib/dina/models/user.rb
CHANGED
@@ -8,7 +8,7 @@ module Dina
|
|
8
8
|
property :lastName, type: :string
|
9
9
|
property :agentId, type: :string
|
10
10
|
property :emailAddress, type: :string
|
11
|
-
property :rolesPerGroup, type: :
|
11
|
+
property :rolesPerGroup, type: :hash
|
12
12
|
property :createdBy, type: :string
|
13
13
|
property :createdOn, type: :time
|
14
14
|
|
data/lib/dina/version.rb
CHANGED
data/lib/dina.rb
CHANGED
@@ -11,7 +11,7 @@ module Dina
|
|
11
11
|
JsonApiClient::Paginating::NestedParamPaginator.page_param = "offset"
|
12
12
|
JsonApiClient::Paginating::NestedParamPaginator.per_page_param = "limit"
|
13
13
|
JsonApiClient::Schema.register array: ArrayCaster
|
14
|
-
JsonApiClient::Schema.register
|
14
|
+
JsonApiClient::Schema.register hash: HashCaster
|
15
15
|
JsonApiClient::Schema.register date: DateCaster
|
16
16
|
JsonApiClient::Schema.register multilingual_title: MultilingualTitleCaster
|
17
17
|
JsonApiClient::Schema.register multilingual_description: MultilingualDescriptionCaster
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dina
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David P. Shorthouse
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json_api_client
|
@@ -146,11 +146,11 @@ files:
|
|
146
146
|
- lib/dina/authentication/authentication.rb
|
147
147
|
- lib/dina/casters/array_caster.rb
|
148
148
|
- lib/dina/casters/date_caster.rb
|
149
|
+
- lib/dina/casters/hash_caster.rb
|
149
150
|
- lib/dina/casters/multilingual_description.rb
|
150
151
|
- lib/dina/casters/multilingual_description_caster.rb
|
151
152
|
- lib/dina/casters/multilingual_title.rb
|
152
153
|
- lib/dina/casters/multilingual_title_caster.rb
|
153
|
-
- lib/dina/casters/object_caster.rb
|
154
154
|
- lib/dina/components/address.rb
|
155
155
|
- lib/dina/components/agent_role.rb
|
156
156
|
- lib/dina/components/determination.rb
|