osso 0.0.3.7 → 0.0.3.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.buildkite/pipeline.yml +5 -3
  3. data/Gemfile.lock +5 -1
  4. data/bin/annotate +1 -0
  5. data/db/schema.rb +11 -54
  6. data/lib/osso/db/migrate/20200714223226_add_identity_provider_service_enum.rb +1 -1
  7. data/lib/osso/db/migrate/20200722230116_add_identity_provider_status_enum_and_use_on_identity_providers.rb +15 -0
  8. data/lib/osso/db/migrate/20200723153750_add_missing_timestamps.rb +35 -0
  9. data/lib/osso/db/migrate/20200723162228_drop_unneeded_tables.rb +9 -0
  10. data/lib/osso/graphql/mutation.rb +7 -1
  11. data/lib/osso/graphql/mutations.rb +7 -1
  12. data/lib/osso/graphql/mutations/add_redirect_uris_to_oauth_client.rb +39 -0
  13. data/lib/osso/graphql/mutations/configure_identity_provider.rb +1 -1
  14. data/lib/osso/graphql/mutations/create_oauth_client.rb +30 -0
  15. data/lib/osso/graphql/mutations/delete_enterprise_account.rb +34 -0
  16. data/lib/osso/graphql/mutations/delete_oauth_client.rb +30 -0
  17. data/lib/osso/graphql/mutations/delete_redirect_uri.rb +38 -0
  18. data/lib/osso/graphql/mutations/mark_redirect_uri_primary.rb +34 -0
  19. data/lib/osso/graphql/mutations/regenerate_oauth_credentials.rb +31 -0
  20. data/lib/osso/graphql/query.rb +15 -2
  21. data/lib/osso/graphql/resolvers/enterprise_accounts.rb +12 -4
  22. data/lib/osso/graphql/resolvers/oauth_clients.rb +1 -1
  23. data/lib/osso/graphql/types.rb +3 -0
  24. data/lib/osso/graphql/types/base_connection.rb +15 -0
  25. data/lib/osso/graphql/types/base_object.rb +4 -0
  26. data/lib/osso/graphql/types/identity_provider.rb +1 -5
  27. data/lib/osso/graphql/types/identity_provider_status.rb +14 -0
  28. data/lib/osso/graphql/types/oauth_client.rb +14 -1
  29. data/lib/osso/graphql/types/redirect_uri.rb +23 -0
  30. data/lib/osso/helpers/auth.rb +13 -12
  31. data/lib/osso/models/access_token.rb +18 -0
  32. data/lib/osso/models/authorization_code.rb +20 -0
  33. data/lib/osso/models/enterprise_account.rb +20 -0
  34. data/lib/osso/models/identity_provider.rb +29 -0
  35. data/lib/osso/models/models.rb +2 -0
  36. data/lib/osso/models/oauth_client.rb +20 -10
  37. data/lib/osso/models/redirect_uri.rb +17 -0
  38. data/lib/osso/models/user.rb +22 -0
  39. data/lib/osso/routes/admin.rb +6 -0
  40. data/lib/osso/routes/auth.rb +1 -1
  41. data/lib/osso/version.rb +1 -1
  42. data/osso-rb.gemspec +1 -0
  43. data/spec/factories/identity_providers.rb +22 -0
  44. data/spec/graphql/mutations/configure_identity_provider_spec.rb +3 -3
  45. data/spec/graphql/mutations/create_oauth_client_spec.rb +55 -0
  46. data/spec/graphql/mutations/delete_enterprise_account_spec.rb +63 -0
  47. data/spec/graphql/mutations/delete_oauth_client_spec.rb +51 -0
  48. data/spec/graphql/query/enterprise_account_spec.rb +1 -1
  49. data/spec/graphql/query/enterprise_accounts_spec.rb +32 -18
  50. data/spec/graphql/query/identity_provider_spec.rb +2 -2
  51. data/spec/graphql/query/{oauth_clients_account_spec.rb → oauth_clients_spec.rb} +2 -0
  52. data/spec/routes/auth_spec.rb +25 -0
  53. metadata +35 -8
  54. data/lib/osso/db/migrate/20200328143303_create_oauth_tables.rb +0 -57
  55. data/lib/osso/graphql/mutations/set_identity_provider.rb +0 -27
  56. data/lib/osso/models/saml_provider.rb +0 -49
  57. data/lib/osso/models/saml_providers/azure_saml_provider.rb +0 -22
  58. data/lib/osso/models/saml_providers/okta_saml_provider.rb +0 -23
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: osso
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3.7
4
+ version: 0.0.3.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Bauch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-21 00:00:00.000000000 Z
11
+ date: 2020-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -178,6 +178,20 @@ dependencies:
178
178
  - - ">="
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: annotate
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: '3.1'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: '3.1'
181
195
  - !ruby/object:Gem::Dependency
182
196
  name: bundler
183
197
  requirement: !ruby/object:Gem::Requirement
@@ -210,6 +224,7 @@ description: This gem includes the main functionality for Osso apps,
210
224
  email:
211
225
  - sbauch@gmail.com
212
226
  executables:
227
+ - annotate
213
228
  - console
214
229
  - setup
215
230
  extensions: []
@@ -229,6 +244,7 @@ files:
229
244
  - LICENSE
230
245
  - README.md
231
246
  - Rakefile
247
+ - bin/annotate
232
248
  - bin/console
233
249
  - bin/setup
234
250
  - config/database.yml
@@ -238,7 +254,6 @@ files:
238
254
  - lib/osso/Rakefile
239
255
  - lib/osso/db/migrate/20190909230109_enable_uuid.rb
240
256
  - lib/osso/db/migrate/20200328135750_create_users.rb
241
- - lib/osso/db/migrate/20200328143303_create_oauth_tables.rb
242
257
  - lib/osso/db/migrate/20200328143305_create_identity_providers.rb
243
258
  - lib/osso/db/migrate/20200411184535_add_provider_id_to_users.rb
244
259
  - lib/osso/db/migrate/20200411192645_create_enterprise_accounts.rb
@@ -250,14 +265,23 @@ files:
250
265
  - lib/osso/db/migrate/20200714223226_add_identity_provider_service_enum.rb
251
266
  - lib/osso/db/migrate/20200715154211_rename_idp_fields_on_identity_provider_to_sso.rb
252
267
  - lib/osso/db/migrate/20200715205801_add_name_to_enterprise_account.rb
268
+ - lib/osso/db/migrate/20200722230116_add_identity_provider_status_enum_and_use_on_identity_providers.rb
269
+ - lib/osso/db/migrate/20200723153750_add_missing_timestamps.rb
270
+ - lib/osso/db/migrate/20200723162228_drop_unneeded_tables.rb
253
271
  - lib/osso/graphql/.DS_Store
254
272
  - lib/osso/graphql/mutation.rb
255
273
  - lib/osso/graphql/mutations.rb
274
+ - lib/osso/graphql/mutations/add_redirect_uris_to_oauth_client.rb
256
275
  - lib/osso/graphql/mutations/base_mutation.rb
257
276
  - lib/osso/graphql/mutations/configure_identity_provider.rb
258
277
  - lib/osso/graphql/mutations/create_enterprise_account.rb
259
278
  - lib/osso/graphql/mutations/create_identity_provider.rb
260
- - lib/osso/graphql/mutations/set_identity_provider.rb
279
+ - lib/osso/graphql/mutations/create_oauth_client.rb
280
+ - lib/osso/graphql/mutations/delete_enterprise_account.rb
281
+ - lib/osso/graphql/mutations/delete_oauth_client.rb
282
+ - lib/osso/graphql/mutations/delete_redirect_uri.rb
283
+ - lib/osso/graphql/mutations/mark_redirect_uri_primary.rb
284
+ - lib/osso/graphql/mutations/regenerate_oauth_credentials.rb
261
285
  - lib/osso/graphql/query.rb
262
286
  - lib/osso/graphql/resolvers.rb
263
287
  - lib/osso/graphql/resolvers/enterprise_account.rb
@@ -265,13 +289,16 @@ files:
265
289
  - lib/osso/graphql/resolvers/oauth_clients.rb
266
290
  - lib/osso/graphql/schema.rb
267
291
  - lib/osso/graphql/types.rb
292
+ - lib/osso/graphql/types/base_connection.rb
268
293
  - lib/osso/graphql/types/base_enum.rb
269
294
  - lib/osso/graphql/types/base_input_object.rb
270
295
  - lib/osso/graphql/types/base_object.rb
271
296
  - lib/osso/graphql/types/enterprise_account.rb
272
297
  - lib/osso/graphql/types/identity_provider.rb
273
298
  - lib/osso/graphql/types/identity_provider_service.rb
299
+ - lib/osso/graphql/types/identity_provider_status.rb
274
300
  - lib/osso/graphql/types/oauth_client.rb
301
+ - lib/osso/graphql/types/redirect_uri.rb
275
302
  - lib/osso/graphql/types/user.rb
276
303
  - lib/osso/helpers/auth.rb
277
304
  - lib/osso/helpers/helpers.rb
@@ -285,9 +312,6 @@ files:
285
312
  - lib/osso/models/models.rb
286
313
  - lib/osso/models/oauth_client.rb
287
314
  - 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
315
  - lib/osso/models/user.rb
292
316
  - lib/osso/rake.rb
293
317
  - lib/osso/routes/admin.rb
@@ -308,10 +332,13 @@ files:
308
332
  - spec/graphql/mutations/configure_identity_provider_spec.rb
309
333
  - spec/graphql/mutations/create_enterprise_account_spec.rb
310
334
  - spec/graphql/mutations/create_identity_provider_spec.rb
335
+ - spec/graphql/mutations/create_oauth_client_spec.rb
336
+ - spec/graphql/mutations/delete_enterprise_account_spec.rb
337
+ - spec/graphql/mutations/delete_oauth_client_spec.rb
311
338
  - spec/graphql/query/enterprise_account_spec.rb
312
339
  - spec/graphql/query/enterprise_accounts_spec.rb
313
340
  - spec/graphql/query/identity_provider_spec.rb
314
- - spec/graphql/query/oauth_clients_account_spec.rb
341
+ - spec/graphql/query/oauth_clients_spec.rb
315
342
  - spec/models/azure_saml_provider_spec.rb
316
343
  - spec/models/identity_provider_spec.rb
317
344
  - spec/models/okta_saml_provider_spec.rb
@@ -1,57 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class CreateOauthTables < ActiveRecord::Migration[6.0]
4
- def change
5
- create_table :oauth_applications, id: :uuid do |t|
6
- t.string :name, null: false
7
- t.string :secret, null: false
8
- t.text :redirect_uri, null: false
9
- t.string :scopes, null: false, default: ''
10
- t.boolean :confidential, null: false, default: true
11
- t.timestamps null: false
12
- end
13
-
14
- create_table :oauth_access_grants, id: :uuid do |t|
15
- t.uuid :resource_owner_id, null: false
16
- t.references :application, type: :uuid, null: false
17
- t.string :token, null: false
18
- t.integer :expires_in, null: false
19
- t.text :redirect_uri, null: false
20
- t.datetime :created_at, null: false
21
- t.datetime :revoked_at
22
- t.string :scopes, null: false, default: ''
23
- end
24
-
25
- add_index :oauth_access_grants, :token, unique: true
26
- add_foreign_key(
27
- :oauth_access_grants,
28
- :oauth_applications,
29
- column: :application_id
30
- )
31
-
32
- create_table :oauth_access_tokens, id: :uuid do |t|
33
- t.uuid :resource_owner_id
34
- t.references :application, type: :uuid
35
- t.string :token, null: false
36
-
37
- t.string :refresh_token
38
- t.integer :expires_in
39
- t.datetime :revoked_at
40
- t.datetime :created_at, null: false
41
- t.string :scopes
42
-
43
- t.string :previous_refresh_token, null: false, default: ''
44
- end
45
-
46
- add_index :oauth_access_tokens, :token, unique: true
47
- add_index :oauth_access_tokens, :refresh_token, unique: true
48
- add_foreign_key(
49
- :oauth_access_tokens,
50
- :oauth_applications,
51
- column: :application_id
52
- )
53
-
54
- add_foreign_key :oauth_access_grants, :users, column: :resource_owner_id
55
- add_foreign_key :oauth_access_tokens, :users, column: :resource_owner_id
56
- end
57
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Osso
4
- module GraphQL
5
- module Mutations
6
- class SetSamlProvider < BaseMutation
7
- null false
8
-
9
- argument :provider, Types::IdentityProviderService, required: true
10
- argument :id, ID, required: true
11
-
12
- field :identity_provider, Types::IdentityProvider, null: false
13
- field :errors, [String], null: false
14
-
15
- def resolve(provider:, id:)
16
- identity_provider = Osso::Models::IdentityProvider.find(id)
17
- identity_provider.service = provider
18
- identity_provider.save!
19
- {
20
- identity_provider: identity_provider,
21
- errors: [],
22
- }
23
- end
24
- end
25
- end
26
- end
27
- end
@@ -1,49 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Osso
4
- module Models
5
- # Base class for SAML Providers
6
- class IdentityProvider < ActiveRecord::Base
7
- NAME_FORMAT = 'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress'
8
- belongs_to :enterprise_account
9
- belongs_to :oauth_client
10
- has_many :users
11
-
12
- before_create :create_enterprise_account
13
-
14
- # def name
15
- # raise(
16
- # NoMethodError,
17
- # '#name must be defined on each provider specific subclass',
18
- # )
19
- # end
20
-
21
- # def saml_options
22
- # raise(
23
- # NoMethodError,
24
- # '#saml_options must be defined on each provider specific subclass',
25
- # )
26
- # end
27
-
28
- def assertion_consumer_service_url
29
- [
30
- ENV.fetch('BASE_URL'),
31
- 'auth',
32
- 'saml',
33
- id,
34
- 'callback',
35
- ].join('/')
36
- end
37
-
38
- alias acs_url assertion_consumer_service_url
39
-
40
- def create_enterprise_account
41
- return if enterprise_account_id
42
-
43
- self.enterprise_account = Models::EnterpriseAccount.create(
44
- domain: domain,
45
- )
46
- end
47
- end
48
- end
49
- end
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Osso
4
- module Models
5
- # Subclass for Azure / ADFS IDP instances
6
- class AzureSamlProvider < Models::IdentityProvider
7
- def name
8
- 'Azure'
9
- end
10
-
11
- def saml_options
12
- attributes.slice(
13
- 'domain',
14
- 'idp_cert',
15
- 'idp_sso_target_url',
16
- ).merge(
17
- issuer: "id:#{id}",
18
- ).symbolize_keys
19
- end
20
- end
21
- end
22
- end
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Osso
4
- module Models
5
- # Subclass for Okta IDP instances
6
- class OktaSamlProvider < Models::IdentityProvider
7
- def name
8
- 'Okta'
9
- end
10
-
11
- def saml_options
12
- attributes.slice(
13
- 'domain',
14
- 'idp_cert',
15
- 'idp_sso_target_url',
16
- ).merge(
17
- issuer: id,
18
- name_identifier_format: NAME_FORMAT,
19
- ).symbolize_keys
20
- end
21
- end
22
- end
23
- end