osso 0.0.3.12 → 0.0.3.13
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/osso/graphql/mutation.rb +1 -1
- data/lib/osso/graphql/mutations.rb +1 -3
- data/lib/osso/graphql/mutations/regenerate_oauth_credentials.rb +2 -2
- data/lib/osso/graphql/mutations/set_redirect_uris.rb +54 -0
- data/lib/osso/graphql/types.rb +1 -0
- data/lib/osso/graphql/types/redirect_uri_input.rb +16 -0
- data/lib/osso/models/oauth_client.rb +4 -0
- data/lib/osso/routes/auth.rb +1 -1
- data/lib/osso/version.rb +1 -1
- metadata +4 -5
- data/lib/osso/graphql/mutations/add_redirect_uris_to_oauth_client.rb +0 -39
- data/lib/osso/graphql/mutations/delete_redirect_uri.rb +0 -38
- data/lib/osso/graphql/mutations/mark_redirect_uri_primary.rb +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f73668d92fba6a919487f77d474b948af28e79b33d60a1c1e2cec8104b0dcff
|
4
|
+
data.tar.gz: f736cdc806facf653635a037f8b9abb8202cda2e811b3b75a2dc52332b12ddab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ea4d47b42b9d2e0ac48833e37ed3375d41d60eefac31166ba81dd86ae3b38f059518beeae625324af095f9c4da4433c83aefd92cb7038cc5e924293e26956e4
|
7
|
+
data.tar.gz: 36969b24b9047a0ab3920e206590697083a314618765dbe7352a5563b4bd93aaca7b50524f442eb994052db594393500a4a157a527d483049f49765367495b39
|
data/Gemfile.lock
CHANGED
@@ -14,7 +14,7 @@ module Osso
|
|
14
14
|
field :delete_enterprise_account, mutation: Mutations::DeleteEnterpriseAccount
|
15
15
|
field :delete_oauth_client, mutation: Mutations::DeleteOauthClient
|
16
16
|
field :delete_redirect_uri, mutation: Mutations::DeleteRedirectUri
|
17
|
-
field :
|
17
|
+
field :set_redirect_uris, mutation: Mutations::SetRedirectUris
|
18
18
|
field :regenerate_oauth_credentials, mutation: Mutations::RegenerateOauthCredentials
|
19
19
|
end
|
20
20
|
end
|
@@ -6,13 +6,11 @@ module Osso
|
|
6
6
|
end
|
7
7
|
|
8
8
|
require_relative 'mutations/base_mutation'
|
9
|
-
require_relative 'mutations/add_redirect_uris_to_oauth_client'
|
10
9
|
require_relative 'mutations/configure_identity_provider'
|
11
10
|
require_relative 'mutations/create_identity_provider'
|
12
11
|
require_relative 'mutations/create_enterprise_account'
|
13
12
|
require_relative 'mutations/create_oauth_client'
|
14
13
|
require_relative 'mutations/delete_enterprise_account'
|
15
14
|
require_relative 'mutations/delete_oauth_client'
|
16
|
-
require_relative 'mutations/delete_redirect_uri'
|
17
|
-
require_relative 'mutations/mark_redirect_uri_primary'
|
18
15
|
require_relative 'mutations/regenerate_oauth_credentials'
|
16
|
+
require_relative 'mutations/set_redirect_uris'
|
@@ -14,9 +14,9 @@ module Osso
|
|
14
14
|
def resolve(id:)
|
15
15
|
oauth_client = Osso::Models::OauthClient.find(id)
|
16
16
|
oauth_client.generate_secrets
|
17
|
-
|
17
|
+
|
18
18
|
return response_data(oauth_client: oauth_client) if oauth_client.save
|
19
|
-
|
19
|
+
|
20
20
|
response_error(errors: oauth_client.errors.full_messages)
|
21
21
|
end
|
22
22
|
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Osso
|
4
|
+
module GraphQL
|
5
|
+
module Mutations
|
6
|
+
class SetRedirectUris < BaseMutation
|
7
|
+
null false
|
8
|
+
|
9
|
+
argument :id, ID, required: true
|
10
|
+
argument :redirect_uris, [Types::RedirectUrisInput], required: true
|
11
|
+
|
12
|
+
field :oauth_client, Types::OauthClient, null: true
|
13
|
+
field :errors, [String], null: false
|
14
|
+
|
15
|
+
def resolve(id:, redirect_uris:)
|
16
|
+
oauth_client = Osso::Models::OauthClient.find(id)
|
17
|
+
|
18
|
+
update_existing(oauth_client, redirect_uris)
|
19
|
+
create_new(oauth_client, redirect_uris)
|
20
|
+
|
21
|
+
response_data(oauth_client: oauth_client.reload)
|
22
|
+
rescue StandardError => e
|
23
|
+
response_error(errors: e)
|
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
|
+
|
32
|
+
def update_existing(oauth_client, redirect_uris)
|
33
|
+
oauth_client.redirect_uris.each do |redirect|
|
34
|
+
updating_index = redirect_uris.index{ |incoming| incoming[:id] == redirect.id }
|
35
|
+
|
36
|
+
if updating_index
|
37
|
+
updating = redirect_uris.delete_at(updating_index)
|
38
|
+
redirect.update(updating.to_h)
|
39
|
+
next
|
40
|
+
end
|
41
|
+
|
42
|
+
redirect.destroy
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def create_new(oauth_client, redirect_uris)
|
47
|
+
redirect_uris.map do |uri|
|
48
|
+
oauth_client.redirect_uris.create(uri.to_h.without(:id))
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/lib/osso/graphql/types.rb
CHANGED
@@ -14,5 +14,6 @@ require_relative 'types/identity_provider_status'
|
|
14
14
|
require_relative 'types/identity_provider'
|
15
15
|
require_relative 'types/enterprise_account'
|
16
16
|
require_relative 'types/redirect_uri'
|
17
|
+
require_relative 'types/redirect_uri_input'
|
17
18
|
require_relative 'types/oauth_client'
|
18
19
|
require_relative 'types/user'
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'graphql'
|
4
|
+
|
5
|
+
module Osso
|
6
|
+
module GraphQL
|
7
|
+
module Types
|
8
|
+
class RedirectUrisInput < Types::BaseInputObject
|
9
|
+
description 'Attributes for creating or updating a collection of redirect URIs for an Oauth Client'
|
10
|
+
argument :id, ID, 'Database ID', required: false
|
11
|
+
argument :uri, String, 'URI value', required: true
|
12
|
+
argument :primary, Boolean, 'Whether the URI is the primary uri used in IDP initiated login', required: true
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/osso/routes/auth.rb
CHANGED
@@ -40,7 +40,7 @@ module Osso
|
|
40
40
|
post '/saml/:id/callback' do
|
41
41
|
provider = Models::IdentityProvider.find(params[:id])
|
42
42
|
oauth_client = provider.oauth_client
|
43
|
-
redirect_uri = env['redirect_uri'] || oauth_client.
|
43
|
+
redirect_uri = env['redirect_uri'] || oauth_client.primary_redirect_uri.uri
|
44
44
|
|
45
45
|
attributes = env['omniauth.auth']&.
|
46
46
|
extra&.
|
data/lib/osso/version.rb
CHANGED
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.
|
4
|
+
version: 0.0.3.13
|
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-08-
|
11
|
+
date: 2020-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -271,7 +271,6 @@ 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
|
275
274
|
- lib/osso/graphql/mutations/base_mutation.rb
|
276
275
|
- lib/osso/graphql/mutations/configure_identity_provider.rb
|
277
276
|
- lib/osso/graphql/mutations/create_enterprise_account.rb
|
@@ -279,9 +278,8 @@ files:
|
|
279
278
|
- lib/osso/graphql/mutations/create_oauth_client.rb
|
280
279
|
- lib/osso/graphql/mutations/delete_enterprise_account.rb
|
281
280
|
- 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
281
|
- lib/osso/graphql/mutations/regenerate_oauth_credentials.rb
|
282
|
+
- lib/osso/graphql/mutations/set_redirect_uris.rb
|
285
283
|
- lib/osso/graphql/query.rb
|
286
284
|
- lib/osso/graphql/resolvers.rb
|
287
285
|
- lib/osso/graphql/resolvers/enterprise_account.rb
|
@@ -299,6 +297,7 @@ files:
|
|
299
297
|
- lib/osso/graphql/types/identity_provider_status.rb
|
300
298
|
- lib/osso/graphql/types/oauth_client.rb
|
301
299
|
- lib/osso/graphql/types/redirect_uri.rb
|
300
|
+
- lib/osso/graphql/types/redirect_uri_input.rb
|
302
301
|
- lib/osso/graphql/types/user.rb
|
303
302
|
- lib/osso/helpers/auth.rb
|
304
303
|
- lib/osso/helpers/helpers.rb
|
@@ -1,39 +0,0 @@
|
|
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
|
@@ -1,38 +0,0 @@
|
|
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
|
@@ -1,34 +0,0 @@
|
|
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
|