uc3-dmp-rds 0.0.24 → 0.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/uc3-dmp-rds/adapter.rb +3 -3
- data/lib/uc3-dmp-rds/authenticator.rb +7 -4
- data/lib/uc3-dmp-rds/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd9a51c00223257f3aa00133b904f00e0c8cede3f166d9521accf5759f928b1a
|
4
|
+
data.tar.gz: 4ca625aa165517ca2f8dd3dd9e4ee14a7188ed44bf65f13dc5f6be65afcd31bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b647640ad6a581e0721cbdd43cd0c6b033c45578ee3e6bb2d44f2c3537d896a5994146f4d995bdb67769a5ff13bfbd38eec29a38124363fd0046d9108829c52
|
7
|
+
data.tar.gz: 319c3c1b995efe7089852318080e6321658aab5bc9099c3c6939e5ca5cb609275f3944e1335ed36794cc16e172049e20d0c4071a71868f06dbc47ac38cefe449
|
data/lib/uc3-dmp-rds/adapter.rb
CHANGED
@@ -36,8 +36,8 @@ module Uc3DmpRds
|
|
36
36
|
host: ENV.fetch('DATABASE_HOST', nil),
|
37
37
|
port: ENV.fetch('DATABASE_PORT', nil),
|
38
38
|
database: ENV.fetch('DATABASE_NAME', nil),
|
39
|
-
username
|
40
|
-
password
|
39
|
+
username:,
|
40
|
+
password:,
|
41
41
|
encoding: 'utf8mb4'
|
42
42
|
)
|
43
43
|
!connection.nil?
|
@@ -50,7 +50,7 @@ module Uc3DmpRds
|
|
50
50
|
def execute_query(sql:, **params)
|
51
51
|
return [] unless sql.is_a?(String) && !sql.strip.empty? && (params.nil? || params.is_a?(Hash))
|
52
52
|
# Verify that all of the kewords are accounted for and that values were supplied
|
53
|
-
raise AdapterError, MSG_KEYWORDS_INVALID unless _verify_params(sql
|
53
|
+
raise AdapterError, MSG_KEYWORDS_INVALID unless _verify_params(sql:, params:)
|
54
54
|
|
55
55
|
ActiveRecord::Base.simple_execute(sql, params)
|
56
56
|
rescue StandardError => e
|
@@ -20,13 +20,13 @@ module Uc3DmpRds
|
|
20
20
|
def authenticate(token:)
|
21
21
|
raise AuthenticatorError, MSG_INVALID_TOKEN if token.nil? || token.to_s.strip.empty?
|
22
22
|
|
23
|
-
users = _query_user(token:
|
23
|
+
users = _query_user(token:)
|
24
24
|
raise AuthenticatorError, MSG_INVALID_TOKEN unless users.is_a?(Array) && users.any?
|
25
25
|
|
26
26
|
user = users.first
|
27
27
|
raise AuthenticatorError, MSG_INACTIVE_USER unless user['active']
|
28
28
|
|
29
|
-
_serialize_user(user:
|
29
|
+
_serialize_user(user:)
|
30
30
|
end
|
31
31
|
|
32
32
|
private
|
@@ -37,7 +37,7 @@ module Uc3DmpRds
|
|
37
37
|
|
38
38
|
sql = <<~SQL.squish
|
39
39
|
SELECT users.id, users.firstname, users.surname, users.email, users.active, i.value orcid,
|
40
|
-
orgs.name org_name, ro.name ror_name, ro.ror_id,
|
40
|
+
orgs.name org_name, ro.name ror_name, ro.ror_id, users.ui_token,
|
41
41
|
(SELECT perms.name FROM users_perms up LEFT OUTER JOIN perms ON up.perm_id = perms.id
|
42
42
|
WHERE users.id = up.user_id AND perms.name = 'modify_templates') perm
|
43
43
|
FROM users
|
@@ -50,10 +50,11 @@ module Uc3DmpRds
|
|
50
50
|
AND i.identifier_scheme_id IN (SELECT sch.id FROM identifier_schemes sch WHERE sch.name = 'orcid')
|
51
51
|
WHERE users.api_token = :token
|
52
52
|
SQL
|
53
|
-
|
53
|
+
ActiveRecord::Base.simple_execute(sql, token: token.to_s.strip)
|
54
54
|
end
|
55
55
|
|
56
56
|
# Convert the ActiveRecord query results into a JSON object
|
57
|
+
# rubocop:disable Metrics/AbcSize
|
57
58
|
def _serialize_user(user:)
|
58
59
|
return {} if user.nil? || user['email'].nil?
|
59
60
|
|
@@ -64,6 +65,7 @@ module Uc3DmpRds
|
|
64
65
|
admin: !user['perm'].nil?,
|
65
66
|
active: user.fetch('active', false)
|
66
67
|
}
|
68
|
+
hash[:token] = user['ui_token'] unless user['ui_token'].nil?
|
67
69
|
hash[:user_id] = { type: 'orcid', identifier: user['orcid'] } unless user['orcid'].nil?
|
68
70
|
return hash if user['org_name'].nil?
|
69
71
|
|
@@ -71,6 +73,7 @@ module Uc3DmpRds
|
|
71
73
|
hash[:affiliation][:affiliation_id] = { type: 'ror', identifier: user['ror_id'] } unless user['ror_id'].nil?
|
72
74
|
JSON.parse(hash.to_json)
|
73
75
|
end
|
76
|
+
# rubocop:enable Metrics/AbcSize
|
74
77
|
end
|
75
78
|
end
|
76
79
|
end
|
data/lib/uc3-dmp-rds/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uc3-dmp-rds
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.26
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Riley
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_record_simple_execute
|
@@ -139,7 +139,7 @@ licenses:
|
|
139
139
|
- MIT
|
140
140
|
metadata:
|
141
141
|
rubygems_mfa_required: 'false'
|
142
|
-
post_install_message:
|
142
|
+
post_install_message:
|
143
143
|
rdoc_options: []
|
144
144
|
require_paths:
|
145
145
|
- lib
|
@@ -147,15 +147,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
147
147
|
requirements:
|
148
148
|
- - ">="
|
149
149
|
- !ruby/object:Gem::Version
|
150
|
-
version: '2
|
150
|
+
version: '3.2'
|
151
151
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
152
|
requirements:
|
153
153
|
- - ">="
|
154
154
|
- !ruby/object:Gem::Version
|
155
155
|
version: '0'
|
156
156
|
requirements: []
|
157
|
-
rubygems_version: 3.
|
158
|
-
signing_key:
|
157
|
+
rubygems_version: 3.4.10
|
158
|
+
signing_key:
|
159
159
|
specification_version: 4
|
160
160
|
summary: DMPTool gem that provides general support for accessing MySQL DB hosted on
|
161
161
|
AWS RDS
|