osso 0.0.3.11 → 0.0.3.12

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ffe9bf4e6f4de963af60c998d318a471e1ff3e33ef5a6c544c8923de762020bc
4
- data.tar.gz: a994f84634c584268e517688ec62b61315da4fa1ab2ea05787305b34deb964f5
3
+ metadata.gz: 3ad3a661abfa7e2251cf7244221ad6e28899c490b732e6c9098f5bf91c903c4e
4
+ data.tar.gz: 3a691f8537a801d2b7302ac3f34e5ea5b74aae9a60fea18470ac50ec5569ec96
5
5
  SHA512:
6
- metadata.gz: 6c4e301385bb83a8ca5f7d66e4a3b3383c7ea3f58f395dc83e1cbadadb2a6896e1852ed787ae9a33a37a2871c3d5c28e5f33e072b7980ad904f958e95b4addb8
7
- data.tar.gz: 8529f13cc30d05946b7fa798b117483dd20b9415d27b6caccecfff228a666b73bfd1f36ceb7e19d7977803159a56aff0eca9075cb380fe7fde3ce560a1847217
6
+ metadata.gz: 35d25337aff8ad4fd8b6d49d34e20226f61725c8a437da30f70cb393a9078b988a4d10847911d0da10ba34f4940488c059829448c006723a5bafc6187a8c5576
7
+ data.tar.gz: 8011819d4ac2c59f0b8fc37470cfd9b2357f9bfeda12e6e4ea1f07c691beba99c2d409b8a2356eb7917edd02c7ae7beaf72860fa70bd3bf31ea5fc4eb6aded79
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- osso (0.0.3.11)
4
+ osso (0.0.3.12)
5
5
  activesupport (>= 6.0.3.2)
6
6
  graphql
7
7
  jwt
@@ -6,12 +6,16 @@ module Osso
6
6
  module GraphQL
7
7
  module Types
8
8
  class MutationType < BaseObject
9
+ field :add_redirect_uris_to_oauth_client, mutation: Mutations::AddRedirectUrisToOauthClient, null: false
9
10
  field :configure_identity_provider, mutation: Mutations::ConfigureIdentityProvider, null: true
10
11
  field :create_identity_provider, mutation: Mutations::CreateIdentityProvider
11
12
  field :create_enterprise_account, mutation: Mutations::CreateEnterpriseAccount
12
13
  field :create_oauth_client, mutation: Mutations::CreateOauthClient
13
14
  field :delete_enterprise_account, mutation: Mutations::DeleteEnterpriseAccount
14
15
  field :delete_oauth_client, mutation: Mutations::DeleteOauthClient
16
+ field :delete_redirect_uri, mutation: Mutations::DeleteRedirectUri
17
+ field :mark_redirect_uri_primary, mutation: Mutations::MarkRedirectUriPrimary
18
+ field :regenerate_oauth_credentials, mutation: Mutations::RegenerateOauthCredentials
15
19
  end
16
20
  end
17
21
  end
@@ -6,9 +6,13 @@ module Osso
6
6
  end
7
7
 
8
8
  require_relative 'mutations/base_mutation'
9
+ require_relative 'mutations/add_redirect_uris_to_oauth_client'
9
10
  require_relative 'mutations/configure_identity_provider'
10
11
  require_relative 'mutations/create_identity_provider'
11
12
  require_relative 'mutations/create_enterprise_account'
12
13
  require_relative 'mutations/create_oauth_client'
13
14
  require_relative 'mutations/delete_enterprise_account'
14
15
  require_relative 'mutations/delete_oauth_client'
16
+ require_relative 'mutations/delete_redirect_uri'
17
+ require_relative 'mutations/mark_redirect_uri_primary'
18
+ require_relative 'mutations/regenerate_oauth_credentials'
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Osso
4
+ module GraphQL
5
+ module Mutations
6
+ class AddRedirectUrisToOauthClient < BaseMutation
7
+ null false
8
+
9
+ argument :oauth_client_id, ID, required: true
10
+ argument :uris, [String], required: true
11
+
12
+ field :oauth_client, Types::OauthClient, null: true
13
+ field :errors, [String], null: false
14
+
15
+ def resolve(oauth_client_id:, uris:)
16
+ oauth_client = Osso::Models::OauthClient.find(oauth_client_id)
17
+
18
+ uris.each do |uri|
19
+ oauth_client.redirect_uris.create(uri: uri)
20
+ end
21
+
22
+ unless oauth_client.primary_redirect_uri
23
+ oauth_client.reload.redirect_uris.first.update(primary: true)
24
+ end
25
+
26
+ response_data(oauth_client: oauth_client.reload)
27
+ rescue StandardError => e
28
+ response_error(errors: e.message)
29
+ end
30
+
31
+ def ready?(*)
32
+ return true if context[:scope] == :admin
33
+
34
+ raise ::GraphQL::ExecutionError, 'Only admin users may mutate OauthClients'
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Osso
4
+ module GraphQL
5
+ module Mutations
6
+ class DeleteRedirectUri < BaseMutation
7
+ null false
8
+
9
+ argument :id, ID, required: true
10
+
11
+ field :oauth_client, Types::OauthClient, null: true
12
+ field :errors, [String], null: false
13
+
14
+ def resolve(id:)
15
+ redirect_uri = Osso::Models::RedirectUri.find(id)
16
+
17
+ oauth_client = redirect_uri.oauth_client
18
+
19
+ redirect_uri.destroy
20
+
21
+ if redirect_uri.primary
22
+ oauth_client.redirect_uris.first&.update(primary: true)
23
+ end
24
+
25
+ return response_data(oauth_client: oauth_client.reload) if redirect_uri.destroy
26
+
27
+ response_error(errors: redirect_uri.errors.full_messages)
28
+ end
29
+
30
+ def ready?(*)
31
+ return true if context[:scope] == :admin
32
+
33
+ raise ::GraphQL::ExecutionError, 'Only admin users may mutate OauthClients'
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Osso
4
+ module GraphQL
5
+ module Mutations
6
+ class MarkRedirectUriPrimary < BaseMutation
7
+ null false
8
+
9
+ argument :id, ID, required: true
10
+
11
+ field :oauth_client, Types::OauthClient, null: true
12
+ field :errors, [String], null: false
13
+
14
+ def resolve(id:)
15
+ redirect_uri = Osso::Models::RedirectUri.find(id)
16
+ oauth_client = redirect_uri.oauth_client
17
+
18
+ oauth_client.redirect_uris.update(primary: false)
19
+ redirect_uri.update(primary: true)
20
+
21
+ response_data(oauth_client: oauth_client.reload)
22
+ rescue StandardError => e
23
+ response_error(errors: e.message)
24
+ end
25
+
26
+ def ready?(*)
27
+ return true if context[:scope] == :admin
28
+
29
+ raise ::GraphQL::ExecutionError, 'Only admin users may mutate OauthClients'
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Osso
4
+ module GraphQL
5
+ module Mutations
6
+ class RegenerateOauthCredentials < BaseMutation
7
+ null false
8
+
9
+ argument :id, ID, required: true
10
+
11
+ field :oauth_client, Types::OauthClient, null: false
12
+ field :errors, [String], null: false
13
+
14
+ def resolve(id:)
15
+ oauth_client = Osso::Models::OauthClient.find(id)
16
+ oauth_client.generate_secrets
17
+
18
+ return response_data(oauth_client: oauth_client) if oauth_client.save
19
+
20
+ response_error(errors: oauth_client.errors.full_messages)
21
+ end
22
+
23
+ def ready?(*)
24
+ return true if context[:scope] == :admin
25
+
26
+ raise ::GraphQL::ExecutionError, 'Only admin users may mutate OauthClients'
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -8,12 +8,13 @@ module Osso
8
8
  argument :sort_column, String, required: false
9
9
  argument :sort_order, String, required: false
10
10
  end
11
- field :oauth_clients, null: true, resolver: Resolvers::OAuthClients
12
11
 
13
12
  field :enterprise_account, null: true, resolver: Resolvers::EnterpriseAccount do
14
13
  argument :domain, String, required: true
15
14
  end
16
15
 
16
+ field :oauth_clients, null: true, resolver: Resolvers::OAuthClients
17
+
17
18
  field(
18
19
  :identity_provider,
19
20
  Types::IdentityProvider,
@@ -22,6 +23,15 @@ module Osso
22
23
  ) do
23
24
  argument :id, ID, required: true
24
25
  end
26
+
27
+ field(
28
+ :oauth_client,
29
+ Types::OauthClient,
30
+ null: true,
31
+ resolve: ->(_obj, args, _context) { Osso::Models::OauthClient.find(args[:id]) },
32
+ ) do
33
+ argument :id, ID, required: true
34
+ end
25
35
  end
26
36
  end
27
37
  end
@@ -13,5 +13,6 @@ require_relative 'types/identity_provider_service'
13
13
  require_relative 'types/identity_provider_status'
14
14
  require_relative 'types/identity_provider'
15
15
  require_relative 'types/enterprise_account'
16
+ require_relative 'types/redirect_uri'
16
17
  require_relative 'types/oauth_client'
17
18
  require_relative 'types/user'
@@ -14,6 +14,7 @@ module Osso
14
14
  field :name, String, null: false
15
15
  field :client_id, String, null: false
16
16
  field :client_secret, String, null: false
17
+ field :redirect_uris, [Types::RedirectUri], null: true
17
18
 
18
19
  def client_id
19
20
  object.identifier
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'graphql'
4
+
5
+ module Osso
6
+ module GraphQL
7
+ module Types
8
+ class RedirectUri < Types::BaseObject
9
+ description 'An allowed redirect URI for an OauthClient'
10
+ implements ::GraphQL::Types::Relay::Node
11
+
12
+ global_id_field :gid
13
+ field :id, ID, null: false
14
+ field :uri, String, null: false
15
+ field :primary, Boolean, null: false
16
+
17
+ def self.authorized?(object, context)
18
+ super && context[:scope] == :admin
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -14,6 +14,8 @@ module Osso
14
14
  redirect ENV['JWT_URL']
15
15
  end
16
16
 
17
+ # use client id in payload to restrict customer
18
+ # users from accessing dev?
17
19
  def enterprise_authorized?(_domain)
18
20
  payload, _args = decode(token)
19
21
 
@@ -9,21 +9,15 @@ module Osso
9
9
  has_many :identity_providers
10
10
  has_many :redirect_uris
11
11
 
12
- before_validation :setup, on: :create
12
+ before_validation :generate_secrets, on: :create
13
13
  validates :name, :secret, presence: true
14
14
  validates :identifier, presence: true, uniqueness: true
15
15
 
16
- def default_redirect_uri
16
+ def primary_redirect_uri
17
17
  redirect_uris.find(&:primary)
18
18
  end
19
19
 
20
- def redirect_uri_values
21
- redirect_uris.map(&:uri)
22
- end
23
-
24
- private
25
-
26
- def setup
20
+ def generate_secrets
27
21
  self.identifier = SecureRandom.hex(16)
28
22
  self.secret = SecureRandom.hex(32)
29
23
  end
@@ -36,6 +36,12 @@ module Osso
36
36
 
37
37
  erb :admin
38
38
  end
39
+
40
+ get '/config/:id' do
41
+ admin_protected!
42
+
43
+ erb :admin
44
+ end
39
45
  end
40
46
  end
41
47
  end
@@ -23,7 +23,7 @@ module Osso
23
23
  self,
24
24
  provider_name: 'saml',
25
25
  identity_provider_id_regex: UUID_REGEXP,
26
- path_prefix: '/saml',
26
+ path_prefix: '/auth/saml',
27
27
  callback_suffix: 'callback',
28
28
  ) do |identity_provider_id, _env|
29
29
  provider = Models::IdentityProvider.find(identity_provider_id)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Osso
4
- VERSION = '0.0.3.11'
4
+ VERSION = '0.0.3.12'
5
5
  end
@@ -3,6 +3,31 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Osso::Auth do
6
+ describe 'get /auth/saml/:uuid' do
7
+ describe 'for an Okta SAML provider' do
8
+ let(:enterprise) { create(:enterprise_with_okta) }
9
+ let(:okta_provider) { enterprise.identity_providers.first }
10
+ it 'uses omniauth saml' do
11
+ get("/auth/saml/#{okta_provider.id}")
12
+
13
+ expect(last_response).to be_redirect
14
+ follow_redirect!
15
+ expect(last_request.url).to match("auth/saml/#{okta_provider.id}")
16
+ end
17
+ end
18
+
19
+ describe 'for an Azure SAML provider' do
20
+ let(:enterprise) { create(:enterprise_with_okta) }
21
+ let(:azure_provider) { enterprise.identity_providers.first }
22
+ it 'uses omniauth saml' do
23
+ get("/auth/saml/#{azure_provider.id}")
24
+
25
+ expect(last_response).to be_redirect
26
+ follow_redirect!
27
+ expect(last_request.url).to match("auth/saml/#{azure_provider.id}")
28
+ end
29
+ end
30
+ end
6
31
  describe 'post /auth/saml/:uuid/callback' do
7
32
  describe 'for an Okta SAML provider' do
8
33
  let(:enterprise) { create(:enterprise_with_okta) }
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.11
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-27 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
@@ -271,6 +271,7 @@ files:
271
271
  - lib/osso/graphql/.DS_Store
272
272
  - lib/osso/graphql/mutation.rb
273
273
  - lib/osso/graphql/mutations.rb
274
+ - lib/osso/graphql/mutations/add_redirect_uris_to_oauth_client.rb
274
275
  - lib/osso/graphql/mutations/base_mutation.rb
275
276
  - lib/osso/graphql/mutations/configure_identity_provider.rb
276
277
  - lib/osso/graphql/mutations/create_enterprise_account.rb
@@ -278,6 +279,9 @@ files:
278
279
  - lib/osso/graphql/mutations/create_oauth_client.rb
279
280
  - lib/osso/graphql/mutations/delete_enterprise_account.rb
280
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
281
285
  - lib/osso/graphql/query.rb
282
286
  - lib/osso/graphql/resolvers.rb
283
287
  - lib/osso/graphql/resolvers/enterprise_account.rb
@@ -294,6 +298,7 @@ files:
294
298
  - lib/osso/graphql/types/identity_provider_service.rb
295
299
  - lib/osso/graphql/types/identity_provider_status.rb
296
300
  - lib/osso/graphql/types/oauth_client.rb
301
+ - lib/osso/graphql/types/redirect_uri.rb
297
302
  - lib/osso/graphql/types/user.rb
298
303
  - lib/osso/helpers/auth.rb
299
304
  - lib/osso/helpers/helpers.rb