uc3-dmp-provenance 0.0.8 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/uc3-dmp-provenance/finder.rb +9 -6
- data/lib/uc3-dmp-provenance/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f3c04c49849d18304637068691a2f26810e166ab70b7ea737c022eaf0f75b55
|
4
|
+
data.tar.gz: 433da4633800604a21914bacf6d1eac8504fd58ae6a32db03f6a5e752f38e4b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d765064e920be446870ef106e514db1906e08d85436abeb44431d73ff9aa4076c8aac9813637424a2ef5032ea153eb2b38ac5b86d2b6217e8f3953c2ebff758e
|
7
|
+
data.tar.gz: 90eadd20dd60a51b6d11e58fef2b1590b2a80fcc4d00a4db1e3807c61e04de4d0a515df36da8bb816a618a1fd3b65ae08886cb0ba7526cc45fedee870a222b38
|
@@ -27,14 +27,15 @@ module Uc3DmpProvenance
|
|
27
27
|
# "client_id": "abcdefghijklmnopqrstuvwxyz"
|
28
28
|
# }
|
29
29
|
# -------------------------------------------------------------------------------------------
|
30
|
-
def from_lambda_cotext(identity:)
|
30
|
+
def from_lambda_cotext(identity:, logger: nil)
|
31
31
|
return nil unless identity.is_a?(Hash) && !identity['iss'].nil? && !identity['client_id'].nil?
|
32
32
|
|
33
33
|
client = Uc3DmpDynamo::Client.new
|
34
|
-
client_name = _cognito_client_id_to_name(claim: identity)
|
34
|
+
client_name = _cognito_client_id_to_name(claim: identity, logger: logger)
|
35
35
|
|
36
36
|
resp = client.get_item(
|
37
|
-
key: { PK: Helper.append_pk_prefix(provenance: client_name), SK: Helper::SK_PROVENANCE_PREFIX }
|
37
|
+
key: { PK: Helper.append_pk_prefix(provenance: client_name), SK: Helper::SK_PROVENANCE_PREFIX },
|
38
|
+
logger: logger
|
38
39
|
)
|
39
40
|
resp.nil? || resp.empty? ? nil : resp
|
40
41
|
end
|
@@ -42,12 +43,13 @@ module Uc3DmpProvenance
|
|
42
43
|
# Fetch the Provenance by it's PK.
|
43
44
|
#
|
44
45
|
# Expecting either the name (e.g. `dmptool` or the qualified PK (e.g. `PROVENANCE#dmptool`)
|
45
|
-
def from_pk(pk:)
|
46
|
+
def from_pk(pk:, logger: logger)
|
46
47
|
return nil if pk.nil?
|
47
48
|
|
48
49
|
pk = Helper.append_pk_prefix(provenance: pk)
|
49
50
|
resp = client.get_item(
|
50
|
-
key: { PK: Helper.append_pk_prefix(provenance: pk), SK: Helper::SK_PROVENANCE_PREFIX }
|
51
|
+
key: { PK: Helper.append_pk_prefix(provenance: pk), SK: Helper::SK_PROVENANCE_PREFIX },
|
52
|
+
logger: logger
|
51
53
|
)
|
52
54
|
resp.nil? || resp.empty? ? nil : resp
|
53
55
|
end
|
@@ -55,10 +57,11 @@ module Uc3DmpProvenance
|
|
55
57
|
private
|
56
58
|
|
57
59
|
# Method to fetch the client's name from the Cognito UserPool based on the client_id
|
58
|
-
def _cognito_client_id_to_name(claim:)
|
60
|
+
def _cognito_client_id_to_name(claim:, logger: nil)
|
59
61
|
return nil if claim.nil? || !claim.is_a?(Hash) || claim['iss'].nil? || claim['client_id'].nil?
|
60
62
|
|
61
63
|
user_pool_id = claim['iss'].split('/').last
|
64
|
+
logger.debug(message: "Cognito User Pool: #{user_pool_id}, ClientId: #{claim['client_id']}") if logger.respond_to?(:debug)
|
62
65
|
Uc3DmpCognito::Client.get_client_name(client_id: claim['client_id'])
|
63
66
|
end
|
64
67
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uc3-dmp-provenance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Riley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|