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.
- checksums.yaml +4 -4
- data/.buildkite/pipeline.yml +5 -3
- data/Gemfile.lock +5 -1
- data/bin/annotate +1 -0
- data/db/schema.rb +11 -54
- data/lib/osso/db/migrate/20200714223226_add_identity_provider_service_enum.rb +1 -1
- data/lib/osso/db/migrate/20200722230116_add_identity_provider_status_enum_and_use_on_identity_providers.rb +15 -0
- data/lib/osso/db/migrate/20200723153750_add_missing_timestamps.rb +35 -0
- data/lib/osso/db/migrate/20200723162228_drop_unneeded_tables.rb +9 -0
- data/lib/osso/graphql/mutation.rb +7 -1
- data/lib/osso/graphql/mutations.rb +7 -1
- data/lib/osso/graphql/mutations/add_redirect_uris_to_oauth_client.rb +39 -0
- data/lib/osso/graphql/mutations/configure_identity_provider.rb +1 -1
- data/lib/osso/graphql/mutations/create_oauth_client.rb +30 -0
- data/lib/osso/graphql/mutations/delete_enterprise_account.rb +34 -0
- data/lib/osso/graphql/mutations/delete_oauth_client.rb +30 -0
- data/lib/osso/graphql/mutations/delete_redirect_uri.rb +38 -0
- data/lib/osso/graphql/mutations/mark_redirect_uri_primary.rb +34 -0
- data/lib/osso/graphql/mutations/regenerate_oauth_credentials.rb +31 -0
- data/lib/osso/graphql/query.rb +15 -2
- data/lib/osso/graphql/resolvers/enterprise_accounts.rb +12 -4
- data/lib/osso/graphql/resolvers/oauth_clients.rb +1 -1
- data/lib/osso/graphql/types.rb +3 -0
- data/lib/osso/graphql/types/base_connection.rb +15 -0
- data/lib/osso/graphql/types/base_object.rb +4 -0
- data/lib/osso/graphql/types/identity_provider.rb +1 -5
- data/lib/osso/graphql/types/identity_provider_status.rb +14 -0
- data/lib/osso/graphql/types/oauth_client.rb +14 -1
- data/lib/osso/graphql/types/redirect_uri.rb +23 -0
- data/lib/osso/helpers/auth.rb +13 -12
- data/lib/osso/models/access_token.rb +18 -0
- data/lib/osso/models/authorization_code.rb +20 -0
- data/lib/osso/models/enterprise_account.rb +20 -0
- data/lib/osso/models/identity_provider.rb +29 -0
- data/lib/osso/models/models.rb +2 -0
- data/lib/osso/models/oauth_client.rb +20 -10
- data/lib/osso/models/redirect_uri.rb +17 -0
- data/lib/osso/models/user.rb +22 -0
- data/lib/osso/routes/admin.rb +6 -0
- data/lib/osso/routes/auth.rb +1 -1
- data/lib/osso/version.rb +1 -1
- data/osso-rb.gemspec +1 -0
- data/spec/factories/identity_providers.rb +22 -0
- data/spec/graphql/mutations/configure_identity_provider_spec.rb +3 -3
- data/spec/graphql/mutations/create_oauth_client_spec.rb +55 -0
- data/spec/graphql/mutations/delete_enterprise_account_spec.rb +63 -0
- data/spec/graphql/mutations/delete_oauth_client_spec.rb +51 -0
- data/spec/graphql/query/enterprise_account_spec.rb +1 -1
- data/spec/graphql/query/enterprise_accounts_spec.rb +32 -18
- data/spec/graphql/query/identity_provider_spec.rb +2 -2
- data/spec/graphql/query/{oauth_clients_account_spec.rb → oauth_clients_spec.rb} +2 -0
- data/spec/routes/auth_spec.rb +25 -0
- metadata +35 -8
- data/lib/osso/db/migrate/20200328143303_create_oauth_tables.rb +0 -57
- data/lib/osso/graphql/mutations/set_identity_provider.rb +0 -27
- data/lib/osso/models/saml_provider.rb +0 -49
- data/lib/osso/models/saml_providers/azure_saml_provider.rb +0 -22
- data/lib/osso/models/saml_providers/okta_saml_provider.rb +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ad3a661abfa7e2251cf7244221ad6e28899c490b732e6c9098f5bf91c903c4e
|
4
|
+
data.tar.gz: 3a691f8537a801d2b7302ac3f34e5ea5b74aae9a60fea18470ac50ec5569ec96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35d25337aff8ad4fd8b6d49d34e20226f61725c8a437da30f70cb393a9078b988a4d10847911d0da10ba34f4940488c059829448c006723a5bafc6187a8c5576
|
7
|
+
data.tar.gz: 8011819d4ac2c59f0b8fc37470cfd9b2357f9bfeda12e6e4ea1f07c691beba99c2d409b8a2356eb7917edd02c7ae7beaf72860fa70bd3bf31ea5fc4eb6aded79
|
data/.buildkite/pipeline.yml
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
steps:
|
2
2
|
- name: ":rspec:"
|
3
3
|
commands:
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
- bundle install
|
5
|
+
- bundle exec rake db:drop
|
6
|
+
- bundle exec rake db:create
|
7
|
+
- RACK_ENV=test bundle exec rake db:migrate
|
8
|
+
- bundle exec rspec
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
osso (0.0.3.
|
4
|
+
osso (0.0.3.12)
|
5
5
|
activesupport (>= 6.0.3.2)
|
6
6
|
graphql
|
7
7
|
jwt
|
@@ -32,6 +32,9 @@ GEM
|
|
32
32
|
addressable (2.7.0)
|
33
33
|
public_suffix (>= 2.0.2, < 5.0)
|
34
34
|
aes_key_wrap (1.0.1)
|
35
|
+
annotate (3.1.1)
|
36
|
+
activerecord (>= 3.2, < 7.0)
|
37
|
+
rake (>= 10.4, < 14.0)
|
35
38
|
ast (2.4.1)
|
36
39
|
attr_required (1.0.1)
|
37
40
|
backports (3.18.1)
|
@@ -160,6 +163,7 @@ PLATFORMS
|
|
160
163
|
ruby
|
161
164
|
|
162
165
|
DEPENDENCIES
|
166
|
+
annotate (~> 3.1)
|
163
167
|
bundler (~> 2.1)
|
164
168
|
database_cleaner-active_record
|
165
169
|
factory_bot
|
data/bin/annotate
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
annotate --require osso.rb --models --model-dir ./lib/osso/models/ --position bottom -k -i
|
data/db/schema.rb
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
#
|
11
11
|
# It's strongly recommended that you check this file into your version control system.
|
12
12
|
|
13
|
-
ActiveRecord::Schema.define(version:
|
13
|
+
ActiveRecord::Schema.define(version: 2020_07_23_162228) do
|
14
14
|
|
15
15
|
# These are extensions that must be enabled in order to support this database
|
16
16
|
enable_extension "pgcrypto"
|
@@ -47,64 +47,21 @@ ActiveRecord::Schema.define(version: 2020_07_15_205801) do
|
|
47
47
|
t.string "external_id"
|
48
48
|
t.uuid "oauth_client_id"
|
49
49
|
t.string "name", null: false
|
50
|
+
t.datetime "created_at", null: false
|
51
|
+
t.datetime "updated_at", null: false
|
50
52
|
t.index ["domain"], name: "index_enterprise_accounts_on_domain", unique: true
|
51
53
|
t.index ["oauth_client_id"], name: "index_enterprise_accounts_on_oauth_client_id"
|
52
54
|
end
|
53
55
|
|
54
|
-
|
55
|
-
|
56
|
-
t.string "domain", null: false
|
57
|
-
t.string "sso_url"
|
58
|
-
t.text "sso_cert"
|
59
|
-
t.uuid "enterprise_account_id"
|
60
|
-
t.uuid "oauth_client_id"
|
61
|
-
t.index ["domain"], name: "index_identity_providers_on_domain"
|
62
|
-
t.index ["enterprise_account_id"], name: "index_identity_providers_on_enterprise_account_id"
|
63
|
-
t.index ["oauth_client_id"], name: "index_identity_providers_on_oauth_client_id"
|
64
|
-
end
|
65
|
-
|
66
|
-
create_table "oauth_access_grants", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
67
|
-
t.uuid "resource_owner_id", null: false
|
68
|
-
t.uuid "application_id", null: false
|
69
|
-
t.string "token", null: false
|
70
|
-
t.integer "expires_in", null: false
|
71
|
-
t.text "redirect_uri", null: false
|
72
|
-
t.datetime "created_at", null: false
|
73
|
-
t.datetime "revoked_at"
|
74
|
-
t.string "scopes", default: "", null: false
|
75
|
-
t.index ["application_id"], name: "index_oauth_access_grants_on_application_id"
|
76
|
-
t.index ["token"], name: "index_oauth_access_grants_on_token", unique: true
|
77
|
-
end
|
78
|
-
|
79
|
-
create_table "oauth_access_tokens", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
80
|
-
t.uuid "resource_owner_id"
|
81
|
-
t.uuid "application_id"
|
82
|
-
t.string "token", null: false
|
83
|
-
t.string "refresh_token"
|
84
|
-
t.integer "expires_in"
|
85
|
-
t.datetime "revoked_at"
|
86
|
-
t.datetime "created_at", null: false
|
87
|
-
t.string "scopes"
|
88
|
-
t.string "previous_refresh_token", default: "", null: false
|
89
|
-
t.index ["application_id"], name: "index_oauth_access_tokens_on_application_id"
|
90
|
-
t.index ["refresh_token"], name: "index_oauth_access_tokens_on_refresh_token", unique: true
|
91
|
-
t.index ["token"], name: "index_oauth_access_tokens_on_token", unique: true
|
92
|
-
end
|
93
|
-
|
94
|
-
create_table "oauth_applications", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
95
|
-
t.string "name", null: false
|
96
|
-
t.string "secret", null: false
|
97
|
-
t.text "redirect_uri", null: false
|
98
|
-
t.string "scopes", default: "", null: false
|
99
|
-
t.boolean "confidential", default: true, null: false
|
100
|
-
t.datetime "created_at", precision: 6, null: false
|
101
|
-
t.datetime "updated_at", precision: 6, null: false
|
102
|
-
end
|
56
|
+
# Could not dump table "identity_providers" because of following StandardError
|
57
|
+
# Unknown type 'identity_provider_status' for column 'status'
|
103
58
|
|
104
59
|
create_table "oauth_clients", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
105
60
|
t.string "name", null: false
|
106
61
|
t.string "secret", null: false
|
107
62
|
t.string "identifier", null: false
|
63
|
+
t.datetime "created_at", null: false
|
64
|
+
t.datetime "updated_at", null: false
|
108
65
|
t.index ["identifier"], name: "index_oauth_clients_on_identifier", unique: true
|
109
66
|
end
|
110
67
|
|
@@ -112,6 +69,8 @@ ActiveRecord::Schema.define(version: 2020_07_15_205801) do
|
|
112
69
|
t.string "uri", null: false
|
113
70
|
t.boolean "primary", default: false, null: false
|
114
71
|
t.uuid "oauth_client_id"
|
72
|
+
t.datetime "created_at", null: false
|
73
|
+
t.datetime "updated_at", null: false
|
115
74
|
t.index ["oauth_client_id"], name: "index_redirect_uris_on_oauth_client_id"
|
116
75
|
t.index ["uri", "primary"], name: "index_redirect_uris_on_uri_and_primary", unique: true
|
117
76
|
end
|
@@ -121,13 +80,11 @@ ActiveRecord::Schema.define(version: 2020_07_15_205801) do
|
|
121
80
|
t.string "idp_id", null: false
|
122
81
|
t.uuid "identity_provider_id"
|
123
82
|
t.uuid "enterprise_account_id"
|
83
|
+
t.datetime "created_at", null: false
|
84
|
+
t.datetime "updated_at", null: false
|
124
85
|
t.index ["email", "idp_id"], name: "index_users_on_email_and_idp_id", unique: true
|
125
86
|
t.index ["enterprise_account_id"], name: "index_users_on_enterprise_account_id"
|
126
87
|
end
|
127
88
|
|
128
|
-
add_foreign_key "oauth_access_grants", "oauth_applications", column: "application_id"
|
129
|
-
add_foreign_key "oauth_access_grants", "users", column: "resource_owner_id"
|
130
|
-
add_foreign_key "oauth_access_tokens", "oauth_applications", column: "application_id"
|
131
|
-
add_foreign_key "oauth_access_tokens", "users", column: "resource_owner_id"
|
132
89
|
add_foreign_key "users", "identity_providers"
|
133
90
|
end
|
@@ -4,7 +4,7 @@ class AddIdentityProviderServiceEnum < ActiveRecord::Migration[6.0]
|
|
4
4
|
execute <<-SQL
|
5
5
|
CREATE TYPE identity_provider_service AS ENUM ('OKTA', 'AZURE');
|
6
6
|
SQL
|
7
|
-
|
7
|
+
change_column :identity_providers, :service, :identity_provider_service
|
8
8
|
end
|
9
9
|
|
10
10
|
def down
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class AddIdentityProviderStatusEnumAndUseOnIdentityProviders < ActiveRecord::Migration[6.0]
|
2
|
+
def up
|
3
|
+
execute <<~SQL
|
4
|
+
CREATE TYPE identity_provider_status AS ENUM ('PENDING', 'CONFIGURED', 'ACTIVE', 'ERROR');
|
5
|
+
SQL
|
6
|
+
add_column :identity_providers, :status, :identity_provider_status, default: 'PENDING'
|
7
|
+
end
|
8
|
+
|
9
|
+
def down
|
10
|
+
remove_column :identity_providers, :status
|
11
|
+
execute <<~SQL
|
12
|
+
DROP TYPE identity_provider_status;
|
13
|
+
SQL
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
class AddMissingTimestamps < ActiveRecord::Migration[6.0]
|
2
|
+
def change
|
3
|
+
add_column :enterprise_accounts, :created_at, :timestamp
|
4
|
+
add_column :enterprise_accounts, :updated_at, :timestamp
|
5
|
+
update "UPDATE enterprise_accounts SET created_at = NOW(), updated_at = NOW()"
|
6
|
+
change_column_null :enterprise_accounts, :created_at, false
|
7
|
+
change_column_null :enterprise_accounts, :updated_at, false
|
8
|
+
|
9
|
+
|
10
|
+
add_column :identity_providers, :created_at, :timestamp
|
11
|
+
add_column :identity_providers, :updated_at, :timestamp
|
12
|
+
update "UPDATE enterprise_accounts SET created_at = NOW(), updated_at = NOW()"
|
13
|
+
change_column_null :enterprise_accounts, :created_at, false
|
14
|
+
change_column_null :enterprise_accounts, :updated_at, false
|
15
|
+
|
16
|
+
add_column :oauth_clients, :created_at, :timestamp
|
17
|
+
add_column :oauth_clients, :updated_at, :timestamp
|
18
|
+
update "UPDATE oauth_clients SET created_at = NOW(), updated_at = NOW()"
|
19
|
+
change_column_null :oauth_clients, :created_at, false
|
20
|
+
change_column_null :oauth_clients, :updated_at, false
|
21
|
+
|
22
|
+
add_column :redirect_uris, :created_at, :timestamp
|
23
|
+
add_column :redirect_uris, :updated_at, :timestamp
|
24
|
+
update "UPDATE redirect_uris SET created_at = NOW(), updated_at = NOW()"
|
25
|
+
change_column_null :redirect_uris, :created_at, false
|
26
|
+
change_column_null :redirect_uris, :updated_at, false
|
27
|
+
|
28
|
+
add_column :users, :created_at, :timestamp
|
29
|
+
add_column :users, :updated_at, :timestamp
|
30
|
+
update "UPDATE users SET created_at = NOW(), updated_at = NOW()"
|
31
|
+
change_column_null :users, :created_at, false
|
32
|
+
change_column_null :users, :updated_at, false
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -6,10 +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
|
-
field :
|
13
|
+
field :create_oauth_client, mutation: Mutations::CreateOauthClient
|
14
|
+
field :delete_enterprise_account, mutation: Mutations::DeleteEnterpriseAccount
|
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
|
13
19
|
end
|
14
20
|
end
|
15
21
|
end
|
@@ -6,7 +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
|
-
require_relative 'mutations/
|
13
|
+
require_relative 'mutations/create_oauth_client'
|
14
|
+
require_relative 'mutations/delete_enterprise_account'
|
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,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Osso
|
4
|
+
module GraphQL
|
5
|
+
module Mutations
|
6
|
+
class CreateOauthClient < BaseMutation
|
7
|
+
null false
|
8
|
+
|
9
|
+
argument :name, String, required: true
|
10
|
+
|
11
|
+
field :oauth_client, Types::OauthClient, null: false
|
12
|
+
field :errors, [String], null: false
|
13
|
+
|
14
|
+
def resolve(**args)
|
15
|
+
oauth_client = Osso::Models::OauthClient.new(args)
|
16
|
+
|
17
|
+
return response_data(oauth_client: oauth_client) if oauth_client.save
|
18
|
+
|
19
|
+
response_error(errors: oauth_client.errors.full_messages)
|
20
|
+
end
|
21
|
+
|
22
|
+
def ready?(*)
|
23
|
+
return true if context[:scope] == :admin
|
24
|
+
|
25
|
+
raise ::GraphQL::ExecutionError, 'Only admin users may mutate OauthClients'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Osso
|
4
|
+
module GraphQL
|
5
|
+
module Mutations
|
6
|
+
class DeleteEnterpriseAccount < BaseMutation
|
7
|
+
null false
|
8
|
+
|
9
|
+
argument :id, ID, required: true
|
10
|
+
|
11
|
+
field :enterprise_account, Types::EnterpriseAccount, null: true
|
12
|
+
field :errors, [String], null: false
|
13
|
+
|
14
|
+
def resolve(id:)
|
15
|
+
enterprise_account = Osso::Models::EnterpriseAccount.find(id)
|
16
|
+
|
17
|
+
return response_data(enterprise_account: nil) if enterprise_account.destroy
|
18
|
+
|
19
|
+
response_error(errors: enterprise_account.errors.full_messages)
|
20
|
+
end
|
21
|
+
|
22
|
+
def ready?(id:)
|
23
|
+
return true if context[:scope] == :admin
|
24
|
+
|
25
|
+
domain = account_domain(id)
|
26
|
+
|
27
|
+
return true if domain == context[:scope]
|
28
|
+
|
29
|
+
raise ::GraphQL::ExecutionError, "This user lacks the scope to mutate records belonging to #{domain}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Osso
|
4
|
+
module GraphQL
|
5
|
+
module Mutations
|
6
|
+
class DeleteOauthClient < 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
|
+
oauth_client = Osso::Models::OauthClient.find(id)
|
16
|
+
|
17
|
+
return response_data(oauth_client: nil) if oauth_client.destroy
|
18
|
+
|
19
|
+
response_error(errors: oauth_client.errors.full_messages)
|
20
|
+
end
|
21
|
+
|
22
|
+
def ready?(*)
|
23
|
+
return true if context[:scope] == :admin
|
24
|
+
|
25
|
+
raise ::GraphQL::ExecutionError, 'Only admin users may mutate OauthClients'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
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
|