osso 0.0.3.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +7 -0
  2. data/.buildkite/hooks/environment +9 -0
  3. data/.buildkite/hooks/pre-command +7 -0
  4. data/.buildkite/pipeline.yml +6 -0
  5. data/.buildkite/template.yml +5 -0
  6. data/.gitignore +10 -0
  7. data/.rspec +1 -0
  8. data/.rubocop.yml +81 -0
  9. data/CODE_OF_CONDUCT.md +130 -0
  10. data/Gemfile +18 -0
  11. data/Gemfile.lock +176 -0
  12. data/LICENSE +111 -0
  13. data/README.md +2 -0
  14. data/Rakefile +14 -0
  15. data/bin/console +8 -0
  16. data/bin/setup +8 -0
  17. data/config/database.yml +14 -0
  18. data/db/schema.rb +133 -0
  19. data/lib/osso.rb +11 -0
  20. data/lib/osso/Rakefile +13 -0
  21. data/lib/osso/db/migrate/20190909230109_enable_uuid.rb +7 -0
  22. data/lib/osso/db/migrate/20200328135750_create_users.rb +12 -0
  23. data/lib/osso/db/migrate/20200328143303_create_oauth_tables.rb +57 -0
  24. data/lib/osso/db/migrate/20200328143305_create_identity_providers.rb +12 -0
  25. data/lib/osso/db/migrate/20200411184535_add_provider_id_to_users.rb +7 -0
  26. data/lib/osso/db/migrate/20200411192645_create_enterprise_accounts.rb +15 -0
  27. data/lib/osso/db/migrate/20200413132407_add_oauth_clients.rb +13 -0
  28. data/lib/osso/db/migrate/20200413142511_create_authorization_codes.rb +15 -0
  29. data/lib/osso/db/migrate/20200413163451_create_access_tokens.rb +13 -0
  30. data/lib/osso/db/migrate/20200502120616_create_redirect_uris_and_drop_from_oauth_clients.rb +13 -0
  31. data/lib/osso/db/migrate/20200502135008_add_oauth_client_id_to_enterprise_accounts_and_identity_providers.rb +6 -0
  32. data/lib/osso/db/migrate/20200714223226_add_identity_provider_service_enum.rb +17 -0
  33. data/lib/osso/db/migrate/20200715154211_rename_idp_fields_on_identity_provider_to_sso.rb +6 -0
  34. data/lib/osso/db/migrate/20200715205801_add_name_to_enterprise_account.rb +5 -0
  35. data/lib/osso/graphql/mutation.rb +16 -0
  36. data/lib/osso/graphql/mutations.rb +12 -0
  37. data/lib/osso/graphql/mutations/base_mutation.rb +41 -0
  38. data/lib/osso/graphql/mutations/configure_identity_provider.rb +36 -0
  39. data/lib/osso/graphql/mutations/create_enterprise_account.rb +25 -0
  40. data/lib/osso/graphql/mutations/create_identity_provider.rb +30 -0
  41. data/lib/osso/graphql/mutations/set_identity_provider.rb +27 -0
  42. data/lib/osso/graphql/query.rb +25 -0
  43. data/lib/osso/graphql/resolvers.rb +12 -0
  44. data/lib/osso/graphql/resolvers/enterprise_account.rb +25 -0
  45. data/lib/osso/graphql/resolvers/enterprise_accounts.rb +17 -0
  46. data/lib/osso/graphql/resolvers/oauth_clients.rb +15 -0
  47. data/lib/osso/graphql/schema.rb +46 -0
  48. data/lib/osso/graphql/types.rb +15 -0
  49. data/lib/osso/graphql/types/base_enum.rb +10 -0
  50. data/lib/osso/graphql/types/base_input_object.rb +10 -0
  51. data/lib/osso/graphql/types/base_object.rb +12 -0
  52. data/lib/osso/graphql/types/enterprise_account.rb +33 -0
  53. data/lib/osso/graphql/types/identity_provider.rb +37 -0
  54. data/lib/osso/graphql/types/identity_provider_service.rb +12 -0
  55. data/lib/osso/graphql/types/oauth_client.rb +20 -0
  56. data/lib/osso/graphql/types/user.rb +17 -0
  57. data/lib/osso/helpers/auth.rb +71 -0
  58. data/lib/osso/helpers/helpers.rb +8 -0
  59. data/lib/osso/lib/app_config.rb +20 -0
  60. data/lib/osso/lib/oauth2_token.rb +38 -0
  61. data/lib/osso/lib/route_map.rb +28 -0
  62. data/lib/osso/models/access_token.rb +29 -0
  63. data/lib/osso/models/authorization_code.rb +14 -0
  64. data/lib/osso/models/enterprise_account.rb +28 -0
  65. data/lib/osso/models/identity_provider.rb +48 -0
  66. data/lib/osso/models/models.rb +16 -0
  67. data/lib/osso/models/oauth_client.rb +32 -0
  68. data/lib/osso/models/redirect_uri.rb +20 -0
  69. data/lib/osso/models/saml_provider.rb +49 -0
  70. data/lib/osso/models/saml_providers/azure_saml_provider.rb +22 -0
  71. data/lib/osso/models/saml_providers/okta_saml_provider.rb +23 -0
  72. data/lib/osso/models/user.rb +24 -0
  73. data/lib/osso/rake.rb +4 -0
  74. data/lib/osso/routes/admin.rb +41 -0
  75. data/lib/osso/routes/auth.rb +67 -0
  76. data/lib/osso/routes/oauth.rb +63 -0
  77. data/lib/osso/routes/routes.rb +10 -0
  78. data/lib/osso/routes/views/error.erb +1 -0
  79. data/lib/osso/routes/views/multiple_providers.erb +1 -0
  80. data/lib/osso/version.rb +5 -0
  81. data/lib/tasks/bootstrap.rake +16 -0
  82. data/osso-rb.gemspec +40 -0
  83. data/spec/factories/authorization_code.rb +10 -0
  84. data/spec/factories/enterprise_account.rb +46 -0
  85. data/spec/factories/identity_providers.rb +49 -0
  86. data/spec/factories/oauth_client.rb +12 -0
  87. data/spec/factories/redirect_uri.rb +14 -0
  88. data/spec/factories/user.rb +18 -0
  89. data/spec/graphql/mutations/configure_identity_provider_spec.rb +75 -0
  90. data/spec/graphql/mutations/create_enterprise_account_spec.rb +68 -0
  91. data/spec/graphql/mutations/create_identity_provider_spec.rb +104 -0
  92. data/spec/graphql/query/enterprise_account_spec.rb +68 -0
  93. data/spec/graphql/query/enterprise_accounts_spec.rb +44 -0
  94. data/spec/graphql/query/identity_provider_spec.rb +65 -0
  95. data/spec/graphql/query/oauth_clients_account_spec.rb +48 -0
  96. data/spec/models/azure_saml_provider_spec.rb +19 -0
  97. data/spec/models/identity_provider_spec.rb +17 -0
  98. data/spec/models/okta_saml_provider_spec.rb +20 -0
  99. data/spec/routes/admin_spec.rb +60 -0
  100. data/spec/routes/app_spec.rb +6 -0
  101. data/spec/routes/auth_spec.rb +112 -0
  102. data/spec/routes/oauth_spec.rb +134 -0
  103. data/spec/spec_helper.rb +68 -0
  104. data/spec/support/spec_app.rb +9 -0
  105. data/spec/support/views/admin.erb +5 -0
  106. metadata +348 -0
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'database_cleaner/active_record'
4
+ require 'factory_bot'
5
+ require 'faker'
6
+ require 'omniauth'
7
+ require 'pry'
8
+ require 'rack/test'
9
+ require 'rspec'
10
+ require 'webmock/rspec'
11
+
12
+ ENV['RACK_ENV'] = 'test'
13
+ ENV['SESSION_SECRET'] = 'supersecret'
14
+ ENV['BASE_URL'] = 'https://example.com'
15
+
16
+ require File.expand_path '../lib/osso.rb', __dir__
17
+
18
+ require File.expand_path 'support/spec_app', __dir__
19
+
20
+ module RSpecMixin
21
+ include Rack::Test::Methods
22
+
23
+ def app
24
+ SpecApp
25
+ end
26
+
27
+ def mock_saml_omniauth(email: 'user@enterprise.com', id: SecureRandom.uuid)
28
+ OmniAuth.config.add_mock(:saml,
29
+ extra: {
30
+ response_object: {
31
+ attributes: {
32
+ 'id': id,
33
+ 'email': email,
34
+ },
35
+ },
36
+ })
37
+ end
38
+
39
+ def last_json_response
40
+ JSON.parse(last_response.body, symbolize_names: true)
41
+ end
42
+
43
+ def spec_views
44
+ File.dirname(__FILE__) + '/support/views'
45
+ end
46
+ end
47
+
48
+ RSpec.configure do |config|
49
+ config.include RSpecMixin
50
+ config.include FactoryBot::Syntax::Methods
51
+
52
+ config.before(:suite) do
53
+ ActiveRecord::Base.establish_connection
54
+ FactoryBot.find_definitions
55
+ DatabaseCleaner.strategy = :transaction
56
+ DatabaseCleaner.clean_with(:truncation)
57
+ end
58
+
59
+ config.around(:each) do |example|
60
+ DatabaseCleaner.cleaning do
61
+ example.run
62
+ end
63
+ end
64
+
65
+ OmniAuth.config.test_mode = true
66
+ OmniAuth.config.logger = Logger.new('/dev/null')
67
+ WebMock.disable_net_connect!(allow_localhost: true)
68
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ class SpecApp < Sinatra::Base
4
+ include Osso::RouteMap
5
+
6
+ get '/health' do
7
+ 'ok'
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ <%#
2
+ NB: this file exists so that the admin routes have something to render in spec.
3
+ In real-world usage, those routes render an index.html file that includes the
4
+ React app.
5
+ %>
metadata ADDED
@@ -0,0 +1,348 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: osso
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3.7
5
+ platform: ruby
6
+ authors:
7
+ - Sam Bauch
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-07-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 6.0.3.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 6.0.3.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: graphql
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: jwt
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: omniauth-multi-provider
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: omniauth-saml
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rack
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 2.1.4
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 2.1.4
97
+ - !ruby/object:Gem::Dependency
98
+ name: rack-contrib
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rack-oauth2
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rake
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: sinatra
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: sinatra-activerecord
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: sinatra-contrib
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :runtime
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: bundler
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: '2.1'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: '2.1'
195
+ - !ruby/object:Gem::Dependency
196
+ name: pry
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
209
+ description: This gem includes the main functionality for Osso apps,
210
+ email:
211
+ - sbauch@gmail.com
212
+ executables:
213
+ - console
214
+ - setup
215
+ extensions: []
216
+ extra_rdoc_files: []
217
+ files:
218
+ - ".DS_Store"
219
+ - ".buildkite/hooks/environment"
220
+ - ".buildkite/hooks/pre-command"
221
+ - ".buildkite/pipeline.yml"
222
+ - ".buildkite/template.yml"
223
+ - ".gitignore"
224
+ - ".rspec"
225
+ - ".rubocop.yml"
226
+ - CODE_OF_CONDUCT.md
227
+ - Gemfile
228
+ - Gemfile.lock
229
+ - LICENSE
230
+ - README.md
231
+ - Rakefile
232
+ - bin/console
233
+ - bin/setup
234
+ - config/database.yml
235
+ - db/schema.rb
236
+ - lib/.DS_Store
237
+ - lib/osso.rb
238
+ - lib/osso/Rakefile
239
+ - lib/osso/db/migrate/20190909230109_enable_uuid.rb
240
+ - lib/osso/db/migrate/20200328135750_create_users.rb
241
+ - lib/osso/db/migrate/20200328143303_create_oauth_tables.rb
242
+ - lib/osso/db/migrate/20200328143305_create_identity_providers.rb
243
+ - lib/osso/db/migrate/20200411184535_add_provider_id_to_users.rb
244
+ - lib/osso/db/migrate/20200411192645_create_enterprise_accounts.rb
245
+ - lib/osso/db/migrate/20200413132407_add_oauth_clients.rb
246
+ - lib/osso/db/migrate/20200413142511_create_authorization_codes.rb
247
+ - lib/osso/db/migrate/20200413163451_create_access_tokens.rb
248
+ - lib/osso/db/migrate/20200502120616_create_redirect_uris_and_drop_from_oauth_clients.rb
249
+ - lib/osso/db/migrate/20200502135008_add_oauth_client_id_to_enterprise_accounts_and_identity_providers.rb
250
+ - lib/osso/db/migrate/20200714223226_add_identity_provider_service_enum.rb
251
+ - lib/osso/db/migrate/20200715154211_rename_idp_fields_on_identity_provider_to_sso.rb
252
+ - lib/osso/db/migrate/20200715205801_add_name_to_enterprise_account.rb
253
+ - lib/osso/graphql/.DS_Store
254
+ - lib/osso/graphql/mutation.rb
255
+ - lib/osso/graphql/mutations.rb
256
+ - lib/osso/graphql/mutations/base_mutation.rb
257
+ - lib/osso/graphql/mutations/configure_identity_provider.rb
258
+ - lib/osso/graphql/mutations/create_enterprise_account.rb
259
+ - lib/osso/graphql/mutations/create_identity_provider.rb
260
+ - lib/osso/graphql/mutations/set_identity_provider.rb
261
+ - lib/osso/graphql/query.rb
262
+ - lib/osso/graphql/resolvers.rb
263
+ - lib/osso/graphql/resolvers/enterprise_account.rb
264
+ - lib/osso/graphql/resolvers/enterprise_accounts.rb
265
+ - lib/osso/graphql/resolvers/oauth_clients.rb
266
+ - lib/osso/graphql/schema.rb
267
+ - lib/osso/graphql/types.rb
268
+ - lib/osso/graphql/types/base_enum.rb
269
+ - lib/osso/graphql/types/base_input_object.rb
270
+ - lib/osso/graphql/types/base_object.rb
271
+ - lib/osso/graphql/types/enterprise_account.rb
272
+ - lib/osso/graphql/types/identity_provider.rb
273
+ - lib/osso/graphql/types/identity_provider_service.rb
274
+ - lib/osso/graphql/types/oauth_client.rb
275
+ - lib/osso/graphql/types/user.rb
276
+ - lib/osso/helpers/auth.rb
277
+ - lib/osso/helpers/helpers.rb
278
+ - lib/osso/lib/app_config.rb
279
+ - lib/osso/lib/oauth2_token.rb
280
+ - lib/osso/lib/route_map.rb
281
+ - lib/osso/models/access_token.rb
282
+ - lib/osso/models/authorization_code.rb
283
+ - lib/osso/models/enterprise_account.rb
284
+ - lib/osso/models/identity_provider.rb
285
+ - lib/osso/models/models.rb
286
+ - lib/osso/models/oauth_client.rb
287
+ - lib/osso/models/redirect_uri.rb
288
+ - lib/osso/models/saml_provider.rb
289
+ - lib/osso/models/saml_providers/azure_saml_provider.rb
290
+ - lib/osso/models/saml_providers/okta_saml_provider.rb
291
+ - lib/osso/models/user.rb
292
+ - lib/osso/rake.rb
293
+ - lib/osso/routes/admin.rb
294
+ - lib/osso/routes/auth.rb
295
+ - lib/osso/routes/oauth.rb
296
+ - lib/osso/routes/routes.rb
297
+ - lib/osso/routes/views/error.erb
298
+ - lib/osso/routes/views/multiple_providers.erb
299
+ - lib/osso/version.rb
300
+ - lib/tasks/bootstrap.rake
301
+ - osso-rb.gemspec
302
+ - spec/factories/authorization_code.rb
303
+ - spec/factories/enterprise_account.rb
304
+ - spec/factories/identity_providers.rb
305
+ - spec/factories/oauth_client.rb
306
+ - spec/factories/redirect_uri.rb
307
+ - spec/factories/user.rb
308
+ - spec/graphql/mutations/configure_identity_provider_spec.rb
309
+ - spec/graphql/mutations/create_enterprise_account_spec.rb
310
+ - spec/graphql/mutations/create_identity_provider_spec.rb
311
+ - spec/graphql/query/enterprise_account_spec.rb
312
+ - spec/graphql/query/enterprise_accounts_spec.rb
313
+ - spec/graphql/query/identity_provider_spec.rb
314
+ - spec/graphql/query/oauth_clients_account_spec.rb
315
+ - spec/models/azure_saml_provider_spec.rb
316
+ - spec/models/identity_provider_spec.rb
317
+ - spec/models/okta_saml_provider_spec.rb
318
+ - spec/routes/admin_spec.rb
319
+ - spec/routes/app_spec.rb
320
+ - spec/routes/auth_spec.rb
321
+ - spec/routes/oauth_spec.rb
322
+ - spec/spec_helper.rb
323
+ - spec/support/spec_app.rb
324
+ - spec/support/views/admin.erb
325
+ homepage: https://github.com/enterprise-oss/osso-rb
326
+ licenses:
327
+ - MIT
328
+ metadata: {}
329
+ post_install_message:
330
+ rdoc_options: []
331
+ require_paths:
332
+ - lib
333
+ required_ruby_version: !ruby/object:Gem::Requirement
334
+ requirements:
335
+ - - ">="
336
+ - !ruby/object:Gem::Version
337
+ version: 2.3.0
338
+ required_rubygems_version: !ruby/object:Gem::Requirement
339
+ requirements:
340
+ - - ">="
341
+ - !ruby/object:Gem::Version
342
+ version: '0'
343
+ requirements: []
344
+ rubygems_version: 3.0.3
345
+ signing_key:
346
+ specification_version: 4
347
+ summary: Main functionality for Osso
348
+ test_files: []