minty 1.0.0
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 +7 -0
- data/.bundle/config +4 -0
- data/.devcontainer/Dockerfile +19 -0
- data/.devcontainer/devcontainer.json +37 -0
- data/.env.example +2 -0
- data/.gemrelease +2 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +33 -0
- data/.github/dependabot.yml +10 -0
- data/.github/stale.yml +20 -0
- data/.gitignore +18 -0
- data/.rspec +3 -0
- data/.rubocop.yml +9 -0
- data/CODE_OF_CONDUCT.md +3 -0
- data/DEPLOYMENT.md +61 -0
- data/DEVELOPMENT.md +35 -0
- data/Dockerfile +5 -0
- data/EXAMPLES.md +195 -0
- data/Gemfile +21 -0
- data/Gemfile.lock +250 -0
- data/Guardfile +39 -0
- data/LICENSE +21 -0
- data/Makefile +5 -0
- data/README.md +88 -0
- data/RUBYGEM.md +9 -0
- data/Rakefile +33 -0
- data/codecov.yml +22 -0
- data/lib/minty/algorithm.rb +7 -0
- data/lib/minty/api/authentication_endpoints.rb +30 -0
- data/lib/minty/api/v2.rb +8 -0
- data/lib/minty/client.rb +7 -0
- data/lib/minty/exception.rb +50 -0
- data/lib/minty/mixins/api_token_struct.rb +4 -0
- data/lib/minty/mixins/headers.rb +19 -0
- data/lib/minty/mixins/httpproxy.rb +125 -0
- data/lib/minty/mixins/initializer.rb +38 -0
- data/lib/minty/mixins/validation.rb +113 -0
- data/lib/minty/mixins.rb +23 -0
- data/lib/minty/version.rb +5 -0
- data/lib/minty.rb +11 -0
- data/lib/minty_client.rb +4 -0
- data/minty.gemspec +39 -0
- data/publish_rubygem.sh +10 -0
- data/spec/integration/lib/minty/api/api_authentication_spec.rb +122 -0
- data/spec/integration/lib/minty/minty_client_spec.rb +92 -0
- data/spec/lib/minty/client_spec.rb +223 -0
- data/spec/lib/minty/mixins/httpproxy_spec.rb +658 -0
- data/spec/lib/minty/mixins/initializer_spec.rb +121 -0
- data/spec/lib/minty/mixins/token_management_spec.rb +129 -0
- data/spec/lib/minty/mixins/validation_spec.rb +559 -0
- data/spec/spec_helper.rb +75 -0
- data/spec/support/credentials.rb +14 -0
- data/spec/support/dummy_class.rb +20 -0
- data/spec/support/dummy_class_for_proxy.rb +6 -0
- data/spec/support/dummy_class_for_restclient.rb +4 -0
- data/spec/support/dummy_class_for_tokens.rb +18 -0
- data/spec/support/import_users.json +13 -0
- data/spec/support/stub_response.rb +3 -0
- metadata +366 -0
data/Gemfile.lock
ADDED
@@ -0,0 +1,250 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
minty (1.0.0)
|
5
|
+
addressable (~> 2.8)
|
6
|
+
jwt (~> 2.5)
|
7
|
+
rest-client (~> 2.1)
|
8
|
+
retryable (~> 3.0)
|
9
|
+
zache (~> 0.12)
|
10
|
+
|
11
|
+
GEM
|
12
|
+
remote: https://rubygems.org/
|
13
|
+
specs:
|
14
|
+
actionpack (7.0.4)
|
15
|
+
actionview (= 7.0.4)
|
16
|
+
activesupport (= 7.0.4)
|
17
|
+
rack (~> 2.0, >= 2.2.0)
|
18
|
+
rack-test (>= 0.6.3)
|
19
|
+
rails-dom-testing (~> 2.0)
|
20
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
21
|
+
actionview (7.0.4)
|
22
|
+
activesupport (= 7.0.4)
|
23
|
+
builder (~> 3.1)
|
24
|
+
erubi (~> 1.4)
|
25
|
+
rails-dom-testing (~> 2.0)
|
26
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
27
|
+
activesupport (7.0.4)
|
28
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
29
|
+
i18n (>= 1.6, < 2)
|
30
|
+
minitest (>= 5.1)
|
31
|
+
tzinfo (~> 2.0)
|
32
|
+
addressable (2.8.1)
|
33
|
+
public_suffix (>= 2.0.2, < 6.0)
|
34
|
+
ast (2.4.2)
|
35
|
+
builder (3.2.4)
|
36
|
+
coderay (1.1.3)
|
37
|
+
concurrent-ruby (1.1.10)
|
38
|
+
coveralls (0.7.1)
|
39
|
+
multi_json (~> 1.3)
|
40
|
+
rest-client
|
41
|
+
simplecov (>= 0.7)
|
42
|
+
term-ansicolor
|
43
|
+
thor
|
44
|
+
crack (0.4.5)
|
45
|
+
rexml
|
46
|
+
crass (1.0.6)
|
47
|
+
diff-lcs (1.5.0)
|
48
|
+
docile (1.4.0)
|
49
|
+
domain_name (0.5.20190701)
|
50
|
+
unf (>= 0.0.5, < 1.0.0)
|
51
|
+
dotenv (2.8.1)
|
52
|
+
dotenv-rails (2.8.1)
|
53
|
+
dotenv (= 2.8.1)
|
54
|
+
railties (>= 3.2)
|
55
|
+
erubi (1.11.0)
|
56
|
+
faker (2.23.0)
|
57
|
+
i18n (>= 1.8.11, < 2)
|
58
|
+
ffi (1.15.5)
|
59
|
+
formatador (1.1.0)
|
60
|
+
fuubar (2.5.1)
|
61
|
+
rspec-core (~> 3.0)
|
62
|
+
ruby-progressbar (~> 1.4)
|
63
|
+
gem-release (0.7.4)
|
64
|
+
guard (2.17.0)
|
65
|
+
formatador (>= 0.2.4)
|
66
|
+
listen (>= 2.7, < 4.0)
|
67
|
+
lumberjack (>= 1.0.12, < 2.0)
|
68
|
+
nenv (~> 0.1)
|
69
|
+
notiffany (~> 0.0)
|
70
|
+
pry (>= 0.9.12)
|
71
|
+
shellany (~> 0.0)
|
72
|
+
thor (>= 0.18.1)
|
73
|
+
guard-compat (1.2.1)
|
74
|
+
guard-rspec (4.7.3)
|
75
|
+
guard (~> 2.1)
|
76
|
+
guard-compat (~> 1.1)
|
77
|
+
rspec (>= 2.99.0, < 4.0)
|
78
|
+
hashdiff (1.0.1)
|
79
|
+
http-accept (1.7.0)
|
80
|
+
http-cookie (1.0.5)
|
81
|
+
domain_name (~> 0.5)
|
82
|
+
i18n (1.12.0)
|
83
|
+
concurrent-ruby (~> 1.0)
|
84
|
+
io-console (0.5.11)
|
85
|
+
irb (1.4.2)
|
86
|
+
reline (>= 0.3.0)
|
87
|
+
json (2.6.2)
|
88
|
+
jwt (2.5.0)
|
89
|
+
listen (3.7.1)
|
90
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
91
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
92
|
+
loofah (2.19.0)
|
93
|
+
crass (~> 1.0.2)
|
94
|
+
nokogiri (>= 1.5.9)
|
95
|
+
lumberjack (1.2.8)
|
96
|
+
method_source (0.9.2)
|
97
|
+
mime-types (3.4.1)
|
98
|
+
mime-types-data (~> 3.2015)
|
99
|
+
mime-types-data (3.2022.0105)
|
100
|
+
minitest (5.16.3)
|
101
|
+
multi_json (1.15.0)
|
102
|
+
nenv (0.3.0)
|
103
|
+
netrc (0.11.0)
|
104
|
+
nokogiri (1.13.9-aarch64-linux)
|
105
|
+
racc (~> 1.4)
|
106
|
+
nokogiri (1.13.9-arm64-darwin)
|
107
|
+
racc (~> 1.4)
|
108
|
+
nokogiri (1.13.9-x86_64-linux)
|
109
|
+
racc (~> 1.4)
|
110
|
+
notiffany (0.1.3)
|
111
|
+
nenv (~> 0.1)
|
112
|
+
shellany (~> 0.0)
|
113
|
+
parallel (1.22.1)
|
114
|
+
parser (3.1.2.1)
|
115
|
+
ast (~> 2.4.1)
|
116
|
+
pp (0.3.0)
|
117
|
+
prettyprint
|
118
|
+
prettyprint (0.1.1)
|
119
|
+
pry (0.12.2)
|
120
|
+
coderay (~> 1.1.0)
|
121
|
+
method_source (~> 0.9.0)
|
122
|
+
pry-nav (0.3.0)
|
123
|
+
pry (>= 0.9.10, < 0.13.0)
|
124
|
+
public_suffix (5.0.0)
|
125
|
+
racc (1.6.0)
|
126
|
+
rack (2.2.4)
|
127
|
+
rack-test (0.8.3)
|
128
|
+
rack (>= 1.0, < 3)
|
129
|
+
rails-dom-testing (2.0.3)
|
130
|
+
activesupport (>= 4.2.0)
|
131
|
+
nokogiri (>= 1.6)
|
132
|
+
rails-html-sanitizer (1.4.3)
|
133
|
+
loofah (~> 2.3)
|
134
|
+
railties (7.0.4)
|
135
|
+
actionpack (= 7.0.4)
|
136
|
+
activesupport (= 7.0.4)
|
137
|
+
method_source
|
138
|
+
rake (>= 12.2)
|
139
|
+
thor (~> 1.0)
|
140
|
+
zeitwerk (~> 2.5)
|
141
|
+
rainbow (3.1.1)
|
142
|
+
rake (13.0.6)
|
143
|
+
rb-fsevent (0.11.2)
|
144
|
+
rb-inotify (0.10.1)
|
145
|
+
ffi (~> 1.0)
|
146
|
+
regexp_parser (2.6.0)
|
147
|
+
reline (0.3.1)
|
148
|
+
io-console (~> 0.5)
|
149
|
+
rest-client (2.1.0)
|
150
|
+
http-accept (>= 1.7.0, < 2.0)
|
151
|
+
http-cookie (>= 1.0.2, < 2.0)
|
152
|
+
mime-types (>= 1.16, < 4.0)
|
153
|
+
netrc (~> 0.8)
|
154
|
+
retryable (3.0.5)
|
155
|
+
rexml (3.2.5)
|
156
|
+
rspec (3.12.0)
|
157
|
+
rspec-core (~> 3.12.0)
|
158
|
+
rspec-expectations (~> 3.12.0)
|
159
|
+
rspec-mocks (~> 3.12.0)
|
160
|
+
rspec-core (3.12.0)
|
161
|
+
rspec-support (~> 3.12.0)
|
162
|
+
rspec-expectations (3.12.0)
|
163
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
164
|
+
rspec-support (~> 3.12.0)
|
165
|
+
rspec-mocks (3.12.0)
|
166
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
167
|
+
rspec-support (~> 3.12.0)
|
168
|
+
rspec-support (3.12.0)
|
169
|
+
rubocop (1.38.0)
|
170
|
+
json (~> 2.3)
|
171
|
+
parallel (~> 1.10)
|
172
|
+
parser (>= 3.1.2.1)
|
173
|
+
rainbow (>= 2.2.2, < 4.0)
|
174
|
+
regexp_parser (>= 1.8, < 3.0)
|
175
|
+
rexml (>= 3.2.5, < 4.0)
|
176
|
+
rubocop-ast (>= 1.23.0, < 2.0)
|
177
|
+
ruby-progressbar (~> 1.7)
|
178
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
179
|
+
rubocop-ast (1.23.0)
|
180
|
+
parser (>= 3.1.1.0)
|
181
|
+
rubocop-rails (2.17.2)
|
182
|
+
activesupport (>= 4.2.0)
|
183
|
+
rack (>= 1.1)
|
184
|
+
rubocop (>= 1.33.0, < 2.0)
|
185
|
+
ruby-progressbar (1.11.0)
|
186
|
+
shellany (0.0.1)
|
187
|
+
simplecov (0.21.2)
|
188
|
+
docile (~> 1.1)
|
189
|
+
simplecov-html (~> 0.11)
|
190
|
+
simplecov_json_formatter (~> 0.1)
|
191
|
+
simplecov-cobertura (2.1.0)
|
192
|
+
rexml
|
193
|
+
simplecov (~> 0.19)
|
194
|
+
simplecov-html (0.12.3)
|
195
|
+
simplecov_json_formatter (0.1.4)
|
196
|
+
sync (0.5.0)
|
197
|
+
term-ansicolor (1.7.1)
|
198
|
+
tins (~> 1.0)
|
199
|
+
terminal-notifier-guard (1.7.0)
|
200
|
+
thor (1.2.1)
|
201
|
+
timecop (0.9.5)
|
202
|
+
tins (1.31.1)
|
203
|
+
sync
|
204
|
+
tzinfo (2.0.5)
|
205
|
+
concurrent-ruby (~> 1.0)
|
206
|
+
unf (0.1.4)
|
207
|
+
unf_ext
|
208
|
+
unf_ext (0.0.8.2)
|
209
|
+
unicode-display_width (2.3.0)
|
210
|
+
vcr (6.1.0)
|
211
|
+
webmock (3.18.1)
|
212
|
+
addressable (>= 2.8.0)
|
213
|
+
crack (>= 0.3.2)
|
214
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
215
|
+
zache (0.12.0)
|
216
|
+
zeitwerk (2.6.1)
|
217
|
+
|
218
|
+
PLATFORMS
|
219
|
+
aarch64-linux
|
220
|
+
arm64-darwin-21
|
221
|
+
x86_64-linux
|
222
|
+
|
223
|
+
DEPENDENCIES
|
224
|
+
bundler
|
225
|
+
coveralls
|
226
|
+
dotenv-rails (~> 2.0)
|
227
|
+
faker (~> 2.0)
|
228
|
+
fuubar (~> 2.0)
|
229
|
+
gem-release (~> 0.7)
|
230
|
+
guard-rspec (~> 4.5)
|
231
|
+
irb
|
232
|
+
minty!
|
233
|
+
pp
|
234
|
+
pry (~> 0.10)
|
235
|
+
pry-nav (~> 0.2)
|
236
|
+
rack (~> 2.1)
|
237
|
+
rack-test (~> 0.6)
|
238
|
+
rake (~> 13.0)
|
239
|
+
rspec (~> 3.11)
|
240
|
+
rubocop
|
241
|
+
rubocop-rails
|
242
|
+
simplecov (~> 0.9)
|
243
|
+
simplecov-cobertura
|
244
|
+
terminal-notifier-guard
|
245
|
+
timecop
|
246
|
+
vcr
|
247
|
+
webmock
|
248
|
+
|
249
|
+
BUNDLED WITH
|
250
|
+
2.3.25
|
data/Guardfile
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
scope group: :unit_test
|
4
|
+
|
5
|
+
group :unit_test do
|
6
|
+
guard 'rspec', cmd:
|
7
|
+
"bundle exec rspec -P \"spec/lib/minty/**/*#{ENV['PATTERN']}*_spec.rb\"--drb --format Fuubar --color" do
|
8
|
+
# run every updated spec file
|
9
|
+
watch(%r{^spec/.+_spec\.rb$})
|
10
|
+
# run the lib specs when a file in lib/ changes
|
11
|
+
watch(%r{^lib/(.+)\.rb$}) { 'spec' }
|
12
|
+
# run all test for helper changes
|
13
|
+
watch('spec/spec_helper.rb') { 'spec' }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
group :integration do
|
18
|
+
guard 'rspec', cmd:
|
19
|
+
"MODE=full bundle exec rspec -P \"spec/integration/**/*#{ENV['PATTERN']}*_spec.rb\" --drb --format Fuubar --color" do
|
20
|
+
# run every updated spec file
|
21
|
+
watch(%r{^spec/.+_spec\.rb$})
|
22
|
+
# run the lib specs when a file in lib/ changes
|
23
|
+
watch(%r{^lib/(.+)\.rb$}) { 'spec' }
|
24
|
+
# run all test for helper changes
|
25
|
+
watch('spec/spec_helper.rb') { 'spec' }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
group :full do
|
30
|
+
guard 'rspec', cmd:
|
31
|
+
'MODE=full bundle exec rspec --drb --format Fuubar --color' do
|
32
|
+
# run every updated spec file
|
33
|
+
watch(%r{^spec/.+_spec\.rb$})
|
34
|
+
# run the lib specs when a file in lib/ changes
|
35
|
+
watch(%r{^lib/(.+)\.rb$}) { 'spec' }
|
36
|
+
# run all test for helper changes
|
37
|
+
watch('spec/spec_helper.rb') { 'spec' }
|
38
|
+
end
|
39
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Minty, Inc. <support@minty.page> (http://minty.page)
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/Makefile
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
default: git
|
2
|
+
git:
|
3
|
+
git add -A
|
4
|
+
git commit -m "Modified `git status --porcelain | grep 'M' | wc -l` file(s), Added `git status --porcelain | grep 'A' | wc -l` file(s), Removed `git status --porcelain | grep 'D' | wc -l` file(s)" -m "`git status --porcelain`"
|
5
|
+
git push -u origin main
|
data/README.md
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
Ruby API client for the [Minty](https://minty.page) platform.
|
2
|
+
|
3
|
+
[](https://github.com/mintypage/ruby/blob/master/LICENSE)
|
4
|
+
|
5
|
+
## Documentation
|
6
|
+
|
7
|
+
- [API documentation](https://www.rubydoc.info/gems/minty) - documentation auto-generated from the code comments that explains all the available features
|
8
|
+
- [Examples](https://github.com/mintypage/ruby/blob/master/EXAMPLES.md) - examples that demonstrate the different ways in which this SDK can be used
|
9
|
+
[FAQ](https://github.com/mintypage/ruby/blob/master/FAQ.md) - frequently asked questions about the SDK
|
10
|
+
- [Docs Site](https://minty.page/docs) - explore our Docs site and learn more about Minty
|
11
|
+
|
12
|
+
## Getting Started
|
13
|
+
|
14
|
+
### Installation
|
15
|
+
|
16
|
+
This gem can be installed directly:
|
17
|
+
|
18
|
+
```bash
|
19
|
+
$ gem install minty
|
20
|
+
```
|
21
|
+
|
22
|
+
or with [Bundler](https://bundler.io/man/bundle-add.1.html):
|
23
|
+
|
24
|
+
```bash
|
25
|
+
bundle add minty
|
26
|
+
```
|
27
|
+
|
28
|
+
### Usage
|
29
|
+
|
30
|
+
Create an instance of `MintyClient` to access properties and methods of the authentication and management APIs:
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
require 'minty'
|
34
|
+
|
35
|
+
client = MintyClient.new(
|
36
|
+
client_id: ENV['AUTH0_RUBY_CLIENT_ID'],
|
37
|
+
client_secret: ENV['AUTH0_RUBY_CLIENT_SECRET'],
|
38
|
+
domain: ENV['AUTH0_RUBY_DOMAIN'],
|
39
|
+
)
|
40
|
+
```
|
41
|
+
|
42
|
+
If `token` is omitted, the SDK will attempt to fetch a new token using the `client_credentials` grant, provided that `client_id` and `client_secret` are provided in the configuration. Once the token is about to expire (or has already expired), a new token will be fetched and cached for future calls.
|
43
|
+
|
44
|
+
For this to work, ensure your application can make a Client Credentials grant (Application settings in Minty > Advanced > Grant Types tab) and that the application is authorized for the Management API: https://minty.page/docs/api-auth/config/using-the-minty-dashboard
|
45
|
+
|
46
|
+
## Authentication API Client
|
47
|
+
|
48
|
+
This SDK provides access to [Authentication API](https://minty.page/docs/api/authentication) endpoints with the `Minty::API::AuthenticationEndpoints` module.
|
49
|
+
|
50
|
+
## Further reading
|
51
|
+
|
52
|
+
- [API authentication in Ruby](https://minty.page/docs/quickstart/backend/ruby)
|
53
|
+
- [API authentication in Rails](https://minty.page/docs/quickstart/backend/rails)
|
54
|
+
- [Managing authentication with Minty (blog)](https://minty.page/blog/rails-5-with-minty/)
|
55
|
+
- [Ruby on Rails workflow with Docker (blog)](https://minty.page/blog/ruby-on-rails-killer-workflow-with-docker-part-1/)
|
56
|
+
|
57
|
+
## Feedback
|
58
|
+
|
59
|
+
### Contributing
|
60
|
+
|
61
|
+
We appreciate feedback and contribution to this repo! Before you get started, please see the following:
|
62
|
+
|
63
|
+
- [Minty's general contribution guidelines](https://github.com/minty/open-source-template/blob/master/GENERAL-CONTRIBUTING.md)
|
64
|
+
- [Minty's code of conduct guidelines](https://github.com/minty/open-source-template/blob/master/CODE-OF-CONDUCT.md)
|
65
|
+
|
66
|
+
### Raise an issue
|
67
|
+
|
68
|
+
To provide feedback or report a bug, please [raise an issue on our issue tracker](https://github.com/mintypage/ruby/issues).
|
69
|
+
|
70
|
+
### Vulnerability Reporting
|
71
|
+
|
72
|
+
Please do not report security vulnerabilities on the public GitHub issue tracker. The [Responsible Disclosure Program](https://minty.page/whitehat) details the procedure for disclosing security issues.
|
73
|
+
|
74
|
+
---
|
75
|
+
|
76
|
+
<p align="center">
|
77
|
+
<picture>
|
78
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://cdn.minty.page/website/sdks/logos/minty_dark_mode.png" width="150">
|
79
|
+
<source media="(prefers-color-scheme: light)" srcset="https://cdn.minty.page/website/sdks/logos/minty_light_mode.png" width="150">
|
80
|
+
<img alt="Minty Logo" src="https://cdn.minty.page/website/sdks/logos/minty_light_mode.png" width="150">
|
81
|
+
</picture>
|
82
|
+
</p>
|
83
|
+
<p align="center">
|
84
|
+
Minty is an easy to implement, adaptable authentication and authorization platform. To learn more checkout <a href="https://minty.page/why-minty">Why Minty?</a>
|
85
|
+
</p>
|
86
|
+
<p align="center">
|
87
|
+
This project is licensed under the MIT license. See the <a href="https://github.com/mintypage/ruby/blob/master/LICENSE"> LICENSE</a> file for more info.
|
88
|
+
</p>
|
data/RUBYGEM.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# Publish the Gem on RubyGems.org
|
2
|
+
|
3
|
+
To publish the gem set `RUBYGEMS_EMAIL` and `RUBYGEMS_PASSWORD` environment variables with your email and password from your RubyGems account respectively.
|
4
|
+
Then run the following [Docker](https://docs.docker.com/engine/installation/) commands in the terminal to build and publish the gem.
|
5
|
+
|
6
|
+
```bash
|
7
|
+
docker build -t minty-publish-rubygem .
|
8
|
+
docker run --rm -e RUBYGEMS_EMAIL="$RUBYGEMS_EMAIL" -e RUBYGEMS_PASSWORD="$RUBYGEMS_PASSWORD" -it minty-publish-rubygem /bin/sh publish_rubygem.sh
|
9
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/gem_tasks'
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'rubocop/rake_task'
|
8
|
+
|
9
|
+
require 'rspec/core/rake_task'
|
10
|
+
|
11
|
+
desc 'Run Rubocop'
|
12
|
+
RuboCop::RakeTask.new(:rubocop)
|
13
|
+
|
14
|
+
desc 'Run Integration Tests'
|
15
|
+
RSpec::Core::RakeTask.new(:integration) do |t|
|
16
|
+
t.pattern = FileList["spec/integration/**/*#{ENV['PATTERN']}*_spec.rb"]
|
17
|
+
end
|
18
|
+
|
19
|
+
desc 'Run Unit Tests'
|
20
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
21
|
+
t.pattern = FileList["spec/lib/minty/**/*#{ENV['PATTERN']}*_spec.rb"]
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'Run All Suites'
|
25
|
+
RSpec::Core::RakeTask.new(:all)
|
26
|
+
|
27
|
+
desc 'Run unit and integration tests'
|
28
|
+
task test: %i[spec integration]
|
29
|
+
|
30
|
+
task default: %i[rubocop test]
|
31
|
+
rescue LoadError
|
32
|
+
puts 'Load Error - No RSpec'
|
33
|
+
end
|
data/codecov.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
coverage:
|
2
|
+
precision: 2
|
3
|
+
round: down
|
4
|
+
range: "60...100"
|
5
|
+
status:
|
6
|
+
project:
|
7
|
+
default:
|
8
|
+
enabled: true
|
9
|
+
target: auto
|
10
|
+
threshold: 5%
|
11
|
+
if_no_uploads: error
|
12
|
+
patch:
|
13
|
+
default:
|
14
|
+
enabled: true
|
15
|
+
target: 80%
|
16
|
+
threshold: 30%
|
17
|
+
if_no_uploads: error
|
18
|
+
changes:
|
19
|
+
default:
|
20
|
+
enabled: true
|
21
|
+
if_no_uploads: error
|
22
|
+
comment: false
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'jwt'
|
4
|
+
|
5
|
+
module Minty
|
6
|
+
module Api
|
7
|
+
module AuthenticationEndpoints
|
8
|
+
def sign_in_url(client_id: @client_id, client_secret: @client_secret, organization: @organization)
|
9
|
+
response = request_with_retry(:get, '/sign_in_url')
|
10
|
+
response['redirect_url']
|
11
|
+
end
|
12
|
+
|
13
|
+
def sign_up_url(client_id: @client_id, client_secret: @client_secret, organization: @organization)
|
14
|
+
response = request_with_retry(:get, '/sign_up_url')
|
15
|
+
response['redirect_url']
|
16
|
+
end
|
17
|
+
|
18
|
+
def forgot_password_url(client_id: @client_id, client_secret: @client_secret, organization: @organization)
|
19
|
+
response = request_with_retry(:get, '/forgot_password_url')
|
20
|
+
response['redirect_url']
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def to_query(hash)
|
26
|
+
hash.map { |k, v| "#{k}=#{CGI.escape(v)}" unless v.nil? }.reject(&:nil?).join('&')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/minty/api/v2.rb
ADDED
data/lib/minty/client.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Minty
|
4
|
+
class Exception < StandardError
|
5
|
+
attr_reader :error_data
|
6
|
+
|
7
|
+
def initialize(message, error_data = {})
|
8
|
+
super(message)
|
9
|
+
@error_data = error_data
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class HTTPError < Minty::Exception
|
14
|
+
def headers
|
15
|
+
error_data[:headers]
|
16
|
+
end
|
17
|
+
|
18
|
+
def http_code
|
19
|
+
error_data[:code]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class Unauthorized < Minty::HTTPError; end
|
24
|
+
class NotFound < Minty::HTTPError; end
|
25
|
+
class Unsupported < Minty::HTTPError; end
|
26
|
+
class ServerError < Minty::HTTPError; end
|
27
|
+
class BadRequest < Minty::HTTPError; end
|
28
|
+
class RequestTimeout < Minty::Exception; end
|
29
|
+
class MissingUserId < Minty::Exception; end
|
30
|
+
class MissingClientId < Minty::Exception; end
|
31
|
+
class MissingOrganizationId < Minty::Exception; end
|
32
|
+
class MissingActionName < Minty::Exception; end
|
33
|
+
class MissingActionId < Minty::Exception; end
|
34
|
+
class MissingExecutionId < Minty::Exception; end
|
35
|
+
class MissingTriggerId < Minty::Exception; end
|
36
|
+
class MissingParameter < Minty::Exception; end
|
37
|
+
class MissingVersionId < Minty::Exception; end
|
38
|
+
class AccessDenied < Minty::HTTPError; end
|
39
|
+
class InvalidParameter < Minty::Exception; end
|
40
|
+
class InvalidCredentials < Minty::Exception; end
|
41
|
+
class InvalidApiNamespace < Minty::Exception; end
|
42
|
+
|
43
|
+
class RateLimitEncountered < Minty::HTTPError
|
44
|
+
def reset
|
45
|
+
Time.at(Integer(headers[:x_ratelimit_reset])).utc
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
class InvalidIdToken < Minty::Exception; end
|
50
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module Minty
|
6
|
+
module Mixins
|
7
|
+
module Headers
|
8
|
+
def client_headers(client_id, client_secret, application_id)
|
9
|
+
{
|
10
|
+
'Content-Type' => 'application/json',
|
11
|
+
'Authorization' => "Bearer #{client_secret}",
|
12
|
+
'API-MINTY-CLIENT-ID' => client_id,
|
13
|
+
'API-MINTY-APPLICATION-ID' => application_id,
|
14
|
+
'Accept' => 'application/json'
|
15
|
+
}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|