uc3-dmp-cognito 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 356409c853a93a4bbc26dd27a381e3103527227c1972889f364a16ffd2d620b8
4
+ data.tar.gz: 7e2391a7010fe12a394755539a0eba3d3f95f60651e5deda85b4bd6d8c3fd3b0
5
+ SHA512:
6
+ metadata.gz: 47dbb6e881d4b32d77c87cc419c1a8e168681d842b2eaa03b9060ef6f2dad0206a20016b3d43932467231170800445e16539b8a31420417401904a48d465b2ed
7
+ data.tar.gz: 209072b636a3957236e77fe0114e805e91425a7f71c8aa04e43ea5de9fc1219b26f5d3c6c23a0a0c310b766cf755d21a83fe673ab46e1cf4cae28305907e3a49
data/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # Uc3DmpCognito
2
+
3
+ Helper methods for accessing the Cognito IdP
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Uc3DmpCognito
4
+ class Uc3DmpCognitoError < StandardError; end
5
+
6
+ # Helper functions for working with Dynamo JSON
7
+ class Client
8
+ MSG_MISSING_POOL = 'No Cognito Pool defined. Expecting `ENV[\'COGNITO_USER_POOL\']'
9
+ MSG_COGNITO_ERROR = 'Cognito User Pool Error - %{msg} - %{trace}'
10
+
11
+ class << self
12
+ # Fetch the name of the client from the client id provided.
13
+ # DMP Provenance names match the Cognito client names
14
+ def get_client_name(client_id:)
15
+ user_pool_id = ENV['COGNITO_USER_POOL']
16
+ raise Uc3DmpCognitoError, MSG_MISSING_POOL if user_pool_id.nil?
17
+
18
+ client = Aws::CognitoIdentityProvider::Client.new(region: ENV.fetch('AWS_REGION', nil))
19
+ resp = client.describe_user_pool_client({ user_pool_id: user_pool_id, client_id: client_id })
20
+ resp&.user_pool_client&.client_name&.downcase
21
+ rescue Aws::Errors::ServiceError => e
22
+ raise Uc3DmpCognitoError, MSG_COGNITO_ERROR % { msg: e.message, trace: e.backtrace }
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Uc3DmpCognito
4
+ VERSION = '0.0.1'
5
+ end
@@ -0,0 +1,11 @@
1
+ # rubocop:disable Naming/FileName
2
+ # frozen_string_literal: true
3
+
4
+ require 'aws-sdk-cognitoidentityprovider'
5
+
6
+ require 'uc3-dmp-cognito/client'
7
+
8
+ module Uc3DmpCognito
9
+
10
+ end
11
+ # rubocop:enable Naming/FileName
metadata ADDED
@@ -0,0 +1,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: uc3-dmp-cognito
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Brian Riley
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-05-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: json
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.6'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: logger
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.4'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.4'
41
+ - !ruby/object:Gem::Dependency
42
+ name: aws-sdk-cognitoidentityprovider
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.73'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.73'
55
+ - !ruby/object:Gem::Dependency
56
+ name: byebug
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 11.1.3
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 11.1.3
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '='
74
+ - !ruby/object:Gem::Version
75
+ version: 3.9.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '='
81
+ - !ruby/object:Gem::Version
82
+ version: 3.9.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 1.50.2
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 1.50.2
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop-rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '='
102
+ - !ruby/object:Gem::Version
103
+ version: 2.20.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '='
109
+ - !ruby/object:Gem::Version
110
+ version: 2.20.0
111
+ description: Helpers for Cognito IdP access
112
+ email:
113
+ - brian.riley@ucop.edu
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - README.md
119
+ - lib/uc3-dmp-cognito.rb
120
+ - lib/uc3-dmp-cognito/client.rb
121
+ - lib/uc3-dmp-cognito/version.rb
122
+ homepage: https://github.com/CDLUC3/dmp-hub-cfn/blob/main/src/sam/gems/uc3-dmp-cognito
123
+ licenses:
124
+ - MIT
125
+ metadata:
126
+ rubygems_mfa_required: 'false'
127
+ post_install_message:
128
+ rdoc_options: []
129
+ require_paths:
130
+ - lib
131
+ required_ruby_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '2.7'
136
+ required_rubygems_version: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ requirements: []
142
+ rubygems_version: 3.1.6
143
+ signing_key:
144
+ specification_version: 4
145
+ summary: DMPTool gem that provides support for Cognito
146
+ test_files: []