descope 1.1.0 → 1.2.0

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.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yaml +4 -4
  3. data/.github/workflows/publish-gem.yaml +2 -2
  4. data/.github/workflows/release-please.yaml +1 -1
  5. data/.release-please-manifest.json +1 -1
  6. data/.rubocop.yml +1 -1
  7. data/.rubocop_todo.yml +1 -1
  8. data/.ruby-version +1 -1
  9. data/CHANGELOG.md +10 -0
  10. data/Gemfile +5 -5
  11. data/Gemfile.lock +32 -32
  12. data/README.md +233 -1
  13. data/lib/descope/api/v1/auth/enchantedlink.rb +76 -9
  14. data/lib/descope/api/v1/management/access_key.rb +8 -7
  15. data/lib/descope/api/v1/management/analytics.rb +62 -0
  16. data/lib/descope/api/v1/management/audit.rb +2 -2
  17. data/lib/descope/api/v1/management/authz.rb +15 -15
  18. data/lib/descope/api/v1/management/common.rb +76 -0
  19. data/lib/descope/api/v1/management/descoper.rb +45 -0
  20. data/lib/descope/api/v1/management/engine.rb +44 -0
  21. data/lib/descope/api/v1/management/fga.rb +64 -0
  22. data/lib/descope/api/v1/management/flow.rb +5 -5
  23. data/lib/descope/api/v1/management/group.rb +42 -0
  24. data/lib/descope/api/v1/management/jwt_template.rb +49 -0
  25. data/lib/descope/api/v1/management/lists.rb +96 -0
  26. data/lib/descope/api/v1/management/management_key.rb +54 -0
  27. data/lib/descope/api/v1/management/outbound_app.rb +112 -0
  28. data/lib/descope/api/v1/management/password.rb +2 -2
  29. data/lib/descope/api/v1/management/permission.rb +4 -4
  30. data/lib/descope/api/v1/management/project.rb +5 -5
  31. data/lib/descope/api/v1/management/role.rb +5 -5
  32. data/lib/descope/api/v1/management/scim.rb +14 -14
  33. data/lib/descope/api/v1/management/scope_claim_mapping.rb +34 -0
  34. data/lib/descope/api/v1/management/sso_application.rb +7 -7
  35. data/lib/descope/api/v1/management/sso_settings.rb +5 -5
  36. data/lib/descope/api/v1/management/tenant.rb +8 -6
  37. data/lib/descope/api/v1/management/third_party_application.rb +190 -0
  38. data/lib/descope/api/v1/management/user.rb +36 -36
  39. data/lib/descope/api/v1/management.rb +22 -0
  40. data/lib/descope/http_client.rb +30 -0
  41. data/lib/descope/mixins/common.rb +1 -0
  42. data/lib/descope/mixins/http.rb +23 -16
  43. data/lib/descope/mixins/initializer.rb +19 -9
  44. data/lib/descope/mixins/requests.rb +24 -0
  45. data/lib/descope/mixins.rb +2 -1
  46. data/lib/descope/version.rb +1 -1
  47. data/spec/integration/lib.descope/api/v1/management/user_spec.rb +1 -1
  48. data/spec/lib.descope/api/v1/auth/enchantedlink_spec.rb +163 -1
  49. data/spec/lib.descope/api/v1/management/access_key_spec.rb +7 -7
  50. data/spec/lib.descope/api/v1/management/analytics_spec.rb +82 -0
  51. data/spec/lib.descope/api/v1/management/audit_spec.rb +2 -2
  52. data/spec/lib.descope/api/v1/management/authz_spec.rb +16 -16
  53. data/spec/lib.descope/api/v1/management/descoper_spec.rb +101 -0
  54. data/spec/lib.descope/api/v1/management/engine_spec.rb +115 -0
  55. data/spec/lib.descope/api/v1/management/fga_spec.rb +169 -0
  56. data/spec/lib.descope/api/v1/management/flow_spec.rb +5 -5
  57. data/spec/lib.descope/api/v1/management/group_spec.rb +72 -0
  58. data/spec/lib.descope/api/v1/management/jwt_template_spec.rb +103 -0
  59. data/spec/lib.descope/api/v1/management/lists_spec.rb +285 -0
  60. data/spec/lib.descope/api/v1/management/management_key_spec.rb +109 -0
  61. data/spec/lib.descope/api/v1/management/outbound_app_spec.rb +236 -0
  62. data/spec/lib.descope/api/v1/management/password_spec.rb +2 -2
  63. data/spec/lib.descope/api/v1/management/permission_spec.rb +4 -4
  64. data/spec/lib.descope/api/v1/management/project_spec.rb +4 -4
  65. data/spec/lib.descope/api/v1/management/role_spec.rb +5 -5
  66. data/spec/lib.descope/api/v1/management/scim_spec.rb +14 -14
  67. data/spec/lib.descope/api/v1/management/scope_claim_mapping_spec.rb +59 -0
  68. data/spec/lib.descope/api/v1/management/sso_application_spec.rb +6 -6
  69. data/spec/lib.descope/api/v1/management/sso_settings_spec.rb +5 -5
  70. data/spec/lib.descope/api/v1/management/tenant_spec.rb +6 -6
  71. data/spec/lib.descope/api/v1/management/third_party_application_spec.rb +171 -0
  72. data/spec/lib.descope/api/v1/management/user_spec.rb +36 -36
  73. data/spec/lib.descope/auth_management_key_spec.rb +151 -0
  74. data/spec/support/client_config.rb +1 -0
  75. data/spec/support/dummy_class.rb +12 -9
  76. metadata +28 -3
@@ -17,7 +17,17 @@ module Descope
17
17
  validate_refresh_token_provided(login_options, refresh_token)
18
18
  body = enchanted_link_compose_signin_body(login_id, uri, login_options)
19
19
  uri = enchanted_link_compose_signin_url
20
- post(uri, body, nil, refresh_token)
20
+ post(uri, body, {}, refresh_token)
21
+ end
22
+
23
+ def enchanted_link_sign_in_with_phone(login_id: nil, uri: nil, login_options: nil, provider_id: nil, template_id: nil, refresh_token: nil)
24
+ validate_login_id(login_id)
25
+ validate_refresh_token_provided(login_options, refresh_token)
26
+ body = enchanted_link_compose_signin_body(login_id, uri, login_options)
27
+ body[:providerId] = provider_id if provider_id
28
+ body[:templateId] = template_id if template_id
29
+ uri = enchanted_link_compose_signin_url(Descope::Mixins::Common::DeliveryMethod::SMS)
30
+ post(uri, body, {}, refresh_token)
21
31
  end
22
32
 
23
33
  def enchanted_link_sign_up(login_id: nil, uri: nil, user: {})
@@ -36,6 +46,23 @@ module Descope
36
46
  post(uri, body)
37
47
  end
38
48
 
49
+ def enchanted_link_sign_up_with_phone(login_id: nil, uri: nil, user: {}, provider_id: nil, template_id: nil)
50
+ method = Descope::Mixins::Common::DeliveryMethod::SMS
51
+
52
+ unless adjust_and_verify_delivery_method(method, login_id, user)
53
+ raise Descope::ArgumentException.new(
54
+ 'Invalid delivery method',
55
+ code: 400
56
+ )
57
+ end
58
+
59
+ body = enchanted_link_compose_signup_body(login_id, uri, user, method)
60
+ body[:providerId] = provider_id if provider_id
61
+ body[:templateId] = template_id if template_id
62
+ uri = enchanted_link_compose_signup_url(method)
63
+ post(uri, body)
64
+ end
65
+
39
66
  def enchanted_link_sign_up_or_in(login_id: nil, uri: nil, login_options: nil)
40
67
  # @see https://docs.descope.com/api/openapi/enchantedlink/operation/SignUpOrInEnchantedLinkEmail/
41
68
  body = enchanted_link_compose_signin_body(login_id, uri, login_options)
@@ -43,6 +70,14 @@ module Descope
43
70
  post(uri, body)
44
71
  end
45
72
 
73
+ def enchanted_link_sign_up_or_in_with_phone(login_id: nil, uri: nil, login_options: nil, provider_id: nil, template_id: nil)
74
+ body = enchanted_link_compose_signin_body(login_id, uri, login_options)
75
+ body[:providerId] = provider_id if provider_id
76
+ body[:templateId] = template_id if template_id
77
+ uri = enchanted_link_compose_sign_up_or_in_url(Descope::Mixins::Common::DeliveryMethod::SMS)
78
+ post(uri, body)
79
+ end
80
+
46
81
  def enchanted_link_update_user_email(login_id: nil, email: nil, uri: nil, add_to_login_ids: nil, on_merge_use_existing: nil, provider_id: nil, template_id: nil, template_options: nil, refresh_token: nil)
47
82
  validate_login_id(login_id)
48
83
  validate_token_not_empty(refresh_token)
@@ -59,6 +94,22 @@ module Descope
59
94
  post(uri, body, {}, refresh_token)
60
95
  end
61
96
 
97
+ def enchanted_link_update_user_phone(login_id: nil, phone: nil, uri: nil, add_to_login_ids: nil, on_merge_use_existing: nil, provider_id: nil, template_id: nil, template_options: nil, refresh_token: nil)
98
+ validate_login_id(login_id)
99
+ validate_token_not_empty(refresh_token)
100
+ validate_phone(Descope::Mixins::Common::DeliveryMethod::SMS, phone)
101
+
102
+ body = enchanted_link_compose_update_user_phone_body(
103
+ login_id, phone, add_to_login_ids, on_merge_use_existing
104
+ )
105
+ body[:redirectUrl] = uri
106
+ body[:providerId] = provider_id if provider_id
107
+ body[:templateId] = template_id if template_id
108
+ body[:templateOptions] = template_options if template_options
109
+ uri = compose_url(UPDATE_USER_PHONE_ENCHANTEDLINK_PATH, Descope::Mixins::Common::DeliveryMethod::SMS)
110
+ post(uri, body, {}, refresh_token)
111
+ end
112
+
62
113
  def enchanted_link_verify_token(token = nil)
63
114
  validate_token_not_empty(token)
64
115
  post(VERIFY_ENCHANTEDLINK_AUTH_PATH, { token: })
@@ -97,19 +148,23 @@ module Descope
97
148
  body
98
149
  end
99
150
 
100
- def enchanted_link_compose_signin_url
101
- compose_url(SIGN_IN_AUTH_ENCHANTEDLINK_PATH, Descope::Mixins::Common::DeliveryMethod::EMAIL)
151
+ def enchanted_link_compose_signin_url(method = nil)
152
+ method = Descope::Mixins::Common::DeliveryMethod::EMAIL if method.nil?
153
+ compose_url(SIGN_IN_AUTH_ENCHANTEDLINK_PATH, method)
102
154
  end
103
155
 
104
- def enchanted_link_compose_signup_url
105
- compose_url(SIGN_UP_AUTH_ENCHANTEDLINK_PATH, Descope::Mixins::Common::DeliveryMethod::EMAIL)
156
+ def enchanted_link_compose_signup_url(method = nil)
157
+ method = Descope::Mixins::Common::DeliveryMethod::EMAIL if method.nil?
158
+ compose_url(SIGN_UP_AUTH_ENCHANTEDLINK_PATH, method)
106
159
  end
107
160
 
108
- def enchanted_link_compose_sign_up_or_in_url
109
- compose_url(SIGN_UP_OR_IN_AUTH_ENCHANTEDLINK_PATH, Descope::Mixins::Common::DeliveryMethod::EMAIL)
161
+ def enchanted_link_compose_sign_up_or_in_url(method = nil)
162
+ method = Descope::Mixins::Common::DeliveryMethod::EMAIL if method.nil?
163
+ compose_url(SIGN_UP_OR_IN_AUTH_ENCHANTEDLINK_PATH, method)
110
164
  end
111
165
 
112
- def enchanted_link_compose_signup_body(login_id, uri, user)
166
+ def enchanted_link_compose_signup_body(login_id, uri, user, method = nil)
167
+ method = Descope::Mixins::Common::DeliveryMethod::EMAIL if method.nil?
113
168
  body = {
114
169
  loginId: login_id,
115
170
  redirectUrl: uri
@@ -118,7 +173,7 @@ module Descope
118
173
  unless user.nil? || user.empty?
119
174
  body[:user] = enchantedlink_user_compose_update_body(**user) unless user.empty?
120
175
 
121
- method_str, val = get_login_id_by_method(method: Descope::Mixins::Common::DeliveryMethod::EMAIL, user:)
176
+ method_str, val = get_login_id_by_method(method:, user:)
122
177
  body[method_str.to_sym] = val
123
178
  end
124
179
 
@@ -137,6 +192,18 @@ module Descope
137
192
  body
138
193
  end
139
194
 
195
+ def enchanted_link_compose_update_user_phone_body(login_id, phone, add_to_login_ids, on_merge_use_existing)
196
+ body = {
197
+ loginId: login_id,
198
+ phone:
199
+ }
200
+
201
+ body[:addToLoginIDs] = add_to_login_ids if add_to_login_ids
202
+ body[:onMergeUseExisting] = on_merge_use_existing if on_merge_use_existing
203
+
204
+ body
205
+ end
206
+
140
207
 
141
208
  private
142
209
  def enchantedlink_user_compose_update_body(login_id: nil, name: nil, phone: nil, email: nil, given_name: nil, middle_name: nil, family_name: nil)
@@ -16,7 +16,8 @@ module Descope
16
16
  role_names ||= []
17
17
  key_tenants ||= []
18
18
  validate_tenants(key_tenants)
19
- post(ACCESS_KEY_CREATE_PATH, access_key_compose_create_body(name, expire_time, role_names, key_tenants, custom_claims))
19
+ mgmt_post(ACCESS_KEY_CREATE_PATH,
20
+ access_key_compose_create_body(name, expire_time, role_names, key_tenants, custom_claims))
20
21
  end
21
22
 
22
23
  def access_key_compose_create_body(name, expire_time, role_names, key_tenants, custom_claims)
@@ -34,7 +35,7 @@ module Descope
34
35
  # @param id [string] The access key id.
35
36
  # @see https://docs.descope.com/api/openapi/accesskeymanagement/operation/LoadAccessKey/
36
37
 
37
- get(ACCESS_KEY_LOAD_PATH, { id: })
38
+ mgmt_get(ACCESS_KEY_LOAD_PATH, { id: })
38
39
  end
39
40
 
40
41
  def search_all_access_keys(tenant_ids = nil)
@@ -43,7 +44,7 @@ module Descope
43
44
  request_params = {
44
45
  tenantIds: tenant_ids
45
46
  }
46
- post(ACCESS_KEYS_SEARCH_PATH, request_params)
47
+ mgmt_post(ACCESS_KEYS_SEARCH_PATH, request_params)
47
48
  end
48
49
 
49
50
  def update_access_key(id: nil, name: nil)
@@ -53,27 +54,27 @@ module Descope
53
54
  id:,
54
55
  name:
55
56
  }
56
- post(ACCESS_KEY_UPDATE_PATH, request_params)
57
+ mgmt_post(ACCESS_KEY_UPDATE_PATH, request_params)
57
58
  end
58
59
 
59
60
  def deactivate_access_key(id)
60
61
  # Deactivate an existing access key. IMPORTANT: This deactivated key will not be usable from this stage.
61
62
  # It will, however, persist, and can be activated again if needed.
62
63
  # @see https://docs.descope.com/api/openapi/accesskeymanagement/operation/DeactivateAccessKey/
63
- post(ACCESS_KEY_DEACTIVATE_PATH, { id: })
64
+ mgmt_post(ACCESS_KEY_DEACTIVATE_PATH, { id: })
64
65
  end
65
66
 
66
67
  def activate_access_key(id)
67
68
  # Activate an existing access key. IMPORTANT: Only deactivated keys can be activated again,
68
69
  # and become usable once more. New access keys are active by default.
69
70
  # @see https://docs.descope.com/api/openapi/accesskeymanagement/operation/ActivateAccessKey/
70
- post(ACCESS_KEY_ACTIVATE_PATH, { id: })
71
+ mgmt_post(ACCESS_KEY_ACTIVATE_PATH, { id: })
71
72
  end
72
73
 
73
74
  def delete_access_key(id)
74
75
  # Delete an existing access key. IMPORTANT: This action is irreversible. Use carefully.
75
76
  # @see https://docs.descope.com/api/openapi/accesskeymanagement/operation/DeleteAccessKey/
76
- post(ACCESS_KEY_DELETE_PATH, { id: })
77
+ mgmt_post(ACCESS_KEY_DELETE_PATH, { id: })
77
78
  end
78
79
  end
79
80
  end
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Descope
4
+ module Api
5
+ module V1
6
+ module Management
7
+ # Management API calls for analytics
8
+ module Analytics
9
+ include Descope::Api::V1::Management::Common
10
+
11
+ def analytics_search(
12
+ from_ts:,
13
+ to_ts:,
14
+ actions: nil,
15
+ excluded_actions: nil,
16
+ devices: nil,
17
+ methods: nil,
18
+ geos: nil,
19
+ tenants: nil,
20
+ group_by_action: false,
21
+ group_by_device: false,
22
+ group_by_method: false,
23
+ group_by_geo: false,
24
+ group_by_tenant: false,
25
+ group_by_referrer: false,
26
+ group_by_created: false
27
+ )
28
+ # Search project analytics based on given parameters
29
+ # from_ts (int): Retrieve records newer than given time in epoch milliseconds
30
+ # to_ts (int): Retrieve records older than given time in epoch milliseconds
31
+ # actions (Array): Optional list of actions to filter by
32
+ # excluded_actions (Array): Optional list of actions to exclude
33
+ # devices (Array): Optional list of devices to filter by
34
+ # methods (Array): Optional list of methods to filter by
35
+ # geos (Array): Optional list of geos to filter by. Geo is currently country code like "US", "IL", etc.
36
+ # tenants (Array): Optional list of tenants to filter by
37
+ # group_by_* (bool): Optional grouping flags for the returned analytics
38
+ request_params = {
39
+ from: from_ts,
40
+ to: to_ts,
41
+ groupByAction: group_by_action,
42
+ groupByDevice: group_by_device,
43
+ groupByMethod: group_by_method,
44
+ groupByGeo: group_by_geo,
45
+ groupByTenant: group_by_tenant,
46
+ groupByReferrer: group_by_referrer,
47
+ groupByCreated: group_by_created
48
+ }
49
+ request_params[:actions] = actions unless actions.nil?
50
+ request_params[:excludedActions] = excluded_actions unless excluded_actions.nil?
51
+ request_params[:devices] = devices unless devices.nil?
52
+ request_params[:methods] = methods unless methods.nil?
53
+ request_params[:geos] = geos unless geos.nil?
54
+ request_params[:tenants] = tenants unless tenants.nil?
55
+
56
+ mgmt_post(ANALYTICS_SEARCH_PATH, request_params)
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -52,7 +52,7 @@ module Descope
52
52
  request_params[:text] = text unless text.nil?
53
53
  request_params[:from] = from_ts.to_i * 1000 unless from_ts.nil?
54
54
  request_params[:to] = to_ts.to_i * 1000 unless to_ts.nil?
55
- res = post(AUDIT_SEARCH, request_params)
55
+ res = mgmt_post(AUDIT_SEARCH, request_params)
56
56
  raise Descope::AuthException, "could not get audits: #{res}" if res['audits'].nil?
57
57
 
58
58
  { 'audits' => res['audits'].map { |audit| convert_audit_record(audit) } }
@@ -79,7 +79,7 @@ module Descope
79
79
  }
80
80
  request_params[:userId] = user_id unless user_id.nil?
81
81
 
82
- post(AUDIT_CREATE_EVENT, request_params)
82
+ mgmt_post(AUDIT_CREATE_EVENT, request_params)
83
83
  end
84
84
 
85
85
  private
@@ -40,17 +40,17 @@ module Descope
40
40
  # Schema name can be used for projects to track versioning.
41
41
  # @see https://docs.descope.com/api/openapi/authz/operation/SaveSchema/
42
42
  request_params = { schema:, upgrade: }
43
- post(AUTHZ_SCHEMA_SAVE, request_params)
43
+ mgmt_post(AUTHZ_SCHEMA_SAVE, request_params)
44
44
  end
45
45
 
46
46
  def authz_delete_schema
47
47
  # Delete the schema for the project which will also delete all relations.
48
- post(AUTHZ_SCHEMA_DELETE)
48
+ mgmt_post(AUTHZ_SCHEMA_DELETE)
49
49
  end
50
50
 
51
51
  def authz_load_schema
52
52
  # Load the schema for the project.
53
- post(AUTHZ_SCHEMA_LOAD)
53
+ mgmt_post(AUTHZ_SCHEMA_LOAD)
54
54
  end
55
55
 
56
56
  def authz_save_namespace(namespace: nil, old_name: nil, schema_name: nil)
@@ -59,14 +59,14 @@ module Descope
59
59
  request_params = { namespace: namespace }
60
60
  request_params[:oldName] = old_name unless old_name.nil?
61
61
  request_params[:schemaName] = schema_name unless schema_name.nil?
62
- post(AUTHZ_NS_SAVE, request_params)
62
+ mgmt_post(AUTHZ_NS_SAVE, request_params)
63
63
  end
64
64
 
65
65
  def authz_delete_namespace(name: nil, schema_name: nil)
66
66
  # Delete the given namespace
67
67
  request_params = { name: name }
68
68
  request_params[:schemaName] = schema_name unless schema_name.nil?
69
- post(AUTHZ_NS_DELETE, request_params)
69
+ mgmt_post(AUTHZ_NS_DELETE, request_params)
70
70
  end
71
71
 
72
72
  def authz_save_relation_definition(relation_definition: nil, namespace: nil, old_name: nil, schema_name: nil)
@@ -78,14 +78,14 @@ module Descope
78
78
  }
79
79
  request_params[:old_name] = old_name unless old_name.nil?
80
80
  request_params[:schemaName] = schema_name unless schema_name.nil?
81
- post(AUTHZ_RD_SAVE, request_params)
81
+ mgmt_post(AUTHZ_RD_SAVE, request_params)
82
82
  end
83
83
 
84
84
  def authz_delete_relation_definition(name: nil, namespace: nil, schema_name: nil)
85
85
  # Delete the given relation definition
86
86
  request_params = { name: , namespace: }
87
87
  request_params[:schemaName] = schema_name unless schema_name.nil?
88
- post(AUTHZ_RD_DELETE, request_params)
88
+ mgmt_post(AUTHZ_RD_DELETE, request_params)
89
89
  end
90
90
 
91
91
  def authz_create_relations(relations = nil)
@@ -114,22 +114,22 @@ module Descope
114
114
  # }
115
115
  # Each relation should have exactly one of: target, targetSet, query
116
116
  # Regarding query above, it should be specified if the target is a set of users that matches the query - all fields are optional
117
- post(AUTHZ_RE_CREATE, { relations: })
117
+ mgmt_post(AUTHZ_RE_CREATE, { relations: })
118
118
  end
119
119
 
120
120
  def authz_delete_relations(relations = nil)
121
121
  # Delete the given relations based on the existing schema
122
- post(AUTHZ_RE_DELETE, { relations: })
122
+ mgmt_post(AUTHZ_RE_DELETE, { relations: })
123
123
  end
124
124
 
125
125
  def authz_delete_relations_for_resources(resources = nil)
126
126
  # Delete all relations for the given resources
127
- post(AUTHZ_RE_DELETE_RESOURCES, { resources: })
127
+ mgmt_post(AUTHZ_RE_DELETE_RESOURCES, { resources: })
128
128
  end
129
129
 
130
130
  def authz_has_relations?(relation_queries = nil)
131
131
  # Queries the given relations to see if they exist returning true if they do
132
- post(AUTHZ_RE_HAS_RELATIONS, { relationQueries: relation_queries })
132
+ mgmt_post(AUTHZ_RE_HAS_RELATIONS, { relationQueries: relation_queries })
133
133
  end
134
134
 
135
135
  def authz_who_can_access?(resource: nil, relation_definition: nil, namespace: nil)
@@ -139,21 +139,21 @@ module Descope
139
139
  relationDefinition: relation_definition,
140
140
  namespace:
141
141
  }
142
- post(AUTHZ_RE_WHO, request_params)
142
+ mgmt_post(AUTHZ_RE_WHO, request_params)
143
143
  end
144
144
 
145
145
  def authz_resource_relations(resources: nil)
146
- post(AUTHZ_RE_RESOURCE, { resources: })
146
+ mgmt_post(AUTHZ_RE_RESOURCE, { resources: })
147
147
  end
148
148
 
149
149
  def authz_target_relations(targets: nil)
150
150
  # Returns the list of all defined relations (not recursive) for the given targets.
151
- post(AUTHZ_RE_TARGETS, { targets: })
151
+ mgmt_post(AUTHZ_RE_TARGETS, { targets: })
152
152
  end
153
153
 
154
154
  def authz_what_can_target_access?(target: nil)
155
155
  # Returns the list of all relations for the given target including derived relations from the schema tree.
156
- res = post(AUTHZ_RE_TARGET_ALL, { target: })
156
+ res = mgmt_post(AUTHZ_RE_TARGET_ALL, { target: })
157
157
  raise Descope::AuthException, "could not get relation for target: #{res}" if res['relations'].nil?
158
158
 
159
159
  res['relations']
@@ -141,6 +141,82 @@ module Descope
141
141
  PROJECT_IMPORT_PATH = '/v1/mgmt/project/import'
142
142
  PROJECT_DELETE_PATH = '/v1/mgmt/project/delete'
143
143
 
144
+ # FGA (Fine-Grained Authorization)
145
+ FGA_SAVE_SCHEMA_PATH = '/v1/mgmt/fga/schema'
146
+ FGA_LOAD_SCHEMA_PATH = '/v1/mgmt/fga/schema'
147
+ FGA_CREATE_RELATIONS_PATH = '/v1/mgmt/fga/relations'
148
+ FGA_DELETE_RELATIONS_PATH = '/v1/mgmt/fga/relations/delete'
149
+ FGA_CHECK_PATH = '/v1/mgmt/fga/check'
150
+ FGA_LOAD_MAPPABLE_SCHEMA_PATH = '/v1/mgmt/fga/mappable/schema'
151
+ FGA_SEARCH_MAPPABLE_RESOURCES_PATH = '/v1/mgmt/fga/mappable/resources'
152
+ FGA_RESOURCES_LOAD_PATH = '/v1/mgmt/fga/resources/load'
153
+ FGA_RESOURCES_SAVE_PATH = '/v1/mgmt/fga/resources/save'
154
+
155
+ # Third Party Application
156
+ THIRD_PARTY_APP_CREATE_PATH = '/v1/mgmt/thirdparty/app/create'
157
+ THIRD_PARTY_APP_UPDATE_PATH = '/v1/mgmt/thirdparty/app/update'
158
+ THIRD_PARTY_APP_PATCH_PATH = '/v1/mgmt/thirdparty/app/patch'
159
+ THIRD_PARTY_APP_DELETE_PATH = '/v1/mgmt/thirdparty/app/delete'
160
+ THIRD_PARTY_APP_LOAD_PATH = '/v1/mgmt/thirdparty/app/load'
161
+ THIRD_PARTY_APP_LOAD_ALL_PATH = '/v1/mgmt/thirdparty/apps/load'
162
+ THIRD_PARTY_APP_SECRET_PATH = '/v1/mgmt/thirdparty/app/secret'
163
+ THIRD_PARTY_APP_ROTATE_PATH = '/v1/mgmt/thirdparty/app/rotate'
164
+ THIRD_PARTY_APP_DELETE_CONSENTS_PATH = '/v1/mgmt/thirdparty/consents/delete'
165
+ THIRD_PARTY_APP_DELETE_TENANT_CONSENTS_PATH = '/v1/mgmt/thirdparty/consents/delete/tenant'
166
+
167
+ # Management Key
168
+ MGMT_KEY_CREATE_PATH = '/v1/mgmt/managementkey'
169
+ MGMT_KEY_UPDATE_PATH = '/v1/mgmt/managementkey'
170
+ MGMT_KEY_GET_PATH = '/v1/mgmt/managementkey'
171
+ MGMT_KEY_DELETE_PATH = '/v1/mgmt/managementkey/delete'
172
+ MGMT_KEY_SEARCH_PATH = '/v1/mgmt/managementkey/search'
173
+
174
+ # Analytics
175
+ ANALYTICS_SEARCH_PATH = '/v1/mgmt/analytics/search'
176
+
177
+ # Descoper
178
+ DESCOPER_CREATE_PATH = '/v1/mgmt/descoper'
179
+ DESCOPER_UPDATE_PATH = '/v1/mgmt/descoper'
180
+ DESCOPER_GET_PATH = '/v1/mgmt/descoper'
181
+ DESCOPER_DELETE_PATH = '/v1/mgmt/descoper'
182
+ DESCOPER_SEARCH_PATH = '/v1/mgmt/descoper/list'
183
+
184
+ # Engine
185
+ ENGINE_CREATE_PATH = '/v1/mgmt/engine/create'
186
+ ENGINE_UPDATE_PATH = '/v1/mgmt/engine/update'
187
+ ENGINE_DELETE_PATH = '/v1/mgmt/engine/delete'
188
+ ENGINE_LOAD_PATH = '/v1/mgmt/engine/load'
189
+ ENGINE_LOAD_ALL_PATH = '/v1/mgmt/engines/load'
190
+ ENGINE_ROTATE_SECRET_PATH = '/v1/mgmt/engine/rotate'
191
+
192
+ # List
193
+ LIST_CREATE_PATH = '/v1/mgmt/list'
194
+ LIST_UPDATE_PATH = '/v1/mgmt/list/update'
195
+ LIST_DELETE_PATH = '/v1/mgmt/list/delete'
196
+ LIST_LOAD_PATH = '/v1/mgmt/list'
197
+ LIST_LOAD_BY_NAME_PATH = '/v1/mgmt/list/name'
198
+ LIST_LOAD_ALL_PATH = '/v1/mgmt/list/all'
199
+ LIST_IMPORT_PATH = '/v1/mgmt/list/import'
200
+ LIST_ADD_IPS_PATH = '/v1/mgmt/list/ip/add'
201
+ LIST_REMOVE_IPS_PATH = '/v1/mgmt/list/ip/remove'
202
+ LIST_CHECK_IP_PATH = '/v1/mgmt/list/ip/check'
203
+ LIST_ADD_TEXTS_PATH = '/v1/mgmt/list/text/add'
204
+ LIST_REMOVE_TEXTS_PATH = '/v1/mgmt/list/text/remove'
205
+ LIST_CHECK_TEXT_PATH = '/v1/mgmt/list/text/check'
206
+ LIST_CLEAR_PATH = '/v1/mgmt/list/clear'
207
+
208
+ # JWT Template
209
+ JWT_TEMPLATE_CREATE_PATH = '/v1/mgmt/jwt/templates/create'
210
+ JWT_TEMPLATE_UPDATE_PATH = '/v1/mgmt/jwt/templates/update'
211
+ JWT_TEMPLATE_DELETE_PATH = '/v1/mgmt/jwt/templates/delete'
212
+ JWT_TEMPLATE_LIST_PATH = '/v1/mgmt/jwt/templates/list'
213
+ JWT_TEMPLATE_LOAD_PATH = '/v1/mgmt/jwt/templates/load'
214
+
215
+ # Scope Claim Mapping (project-wide OIDC scope-to-claim mapping)
216
+ SCOPE_CLAIM_MAPPING_GET_PATH = '/v1/mgmt/scopeClaimMapping/get'
217
+ SCOPE_CLAIM_MAPPING_SET_PATH = '/v1/mgmt/scopeClaimMapping/set'
218
+ SCOPE_CLAIM_MAPPING_DELETE_PATH = '/v1/mgmt/scopeClaimMapping/delete'
219
+
144
220
  def associated_tenants_to_hash_array(associated_tenants = [])
145
221
  # Represents a tenant association for a User or Access Key. The tenant_id is required to denote
146
222
  # which tenant the user or access key belongs to. The role_names array is an optional list of
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Descope
4
+ module Api
5
+ module V1
6
+ module Management
7
+ # Management API calls for Descoper
8
+ module Descoper
9
+ include Descope::Api::V1::Management::Common
10
+
11
+ def create_descoper(descopers = nil)
12
+ # Create the given descopers.
13
+ # descopers (Array): the descopers to create.
14
+ mgmt_put(DESCOPER_CREATE_PATH, { descopers: descopers })
15
+ end
16
+
17
+ def update_descoper(id: nil, attributes: nil, rbac: nil)
18
+ # Update the given descoper by id.
19
+ request_params = {
20
+ id: id,
21
+ attributes: attributes,
22
+ rbac: rbac
23
+ }
24
+ mgmt_patch(DESCOPER_UPDATE_PATH, request_params)
25
+ end
26
+
27
+ def get_descoper(id: nil)
28
+ # Get a descoper by id.
29
+ mgmt_get(DESCOPER_GET_PATH, { id: id })
30
+ end
31
+
32
+ def delete_descoper(id: nil)
33
+ # Delete a descoper by id.
34
+ mgmt_delete(DESCOPER_DELETE_PATH, { id: id })
35
+ end
36
+
37
+ def search_descopers
38
+ # Search (list) all descopers.
39
+ mgmt_post(DESCOPER_SEARCH_PATH, {})
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Descope
4
+ module Api
5
+ module V1
6
+ module Management
7
+ # Management API calls for Engine
8
+ module Engine
9
+ include Descope::Api::V1::Management::Common
10
+
11
+ def create_engine(name:)
12
+ # Create a new engine with the given name.
13
+ mgmt_post(ENGINE_CREATE_PATH, { name: })
14
+ end
15
+
16
+ def update_engine(id:, name:)
17
+ # Update an existing engine with the given id and name.
18
+ mgmt_post(ENGINE_UPDATE_PATH, { id:, name: })
19
+ end
20
+
21
+ def delete_engine(id:)
22
+ # Delete an existing engine. IMPORTANT: This action is irreversible. Use carefully.
23
+ mgmt_post(ENGINE_DELETE_PATH, { id: })
24
+ end
25
+
26
+ def load_engine(id:)
27
+ # Load engine by id.
28
+ mgmt_get(ENGINE_LOAD_PATH, { id: })
29
+ end
30
+
31
+ def load_all_engines
32
+ # Load all engines.
33
+ mgmt_get(ENGINE_LOAD_ALL_PATH)
34
+ end
35
+
36
+ def rotate_engine_secret(id:)
37
+ # Rotate the secret for the given engine.
38
+ mgmt_post(ENGINE_ROTATE_SECRET_PATH, { id: })
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Descope
4
+ module Api
5
+ module V1
6
+ module Management
7
+ # Management API calls for FGA (Fine-Grained Authorization)
8
+ module FGA
9
+ include Descope::Api::V1::Management::Common
10
+
11
+ def fga_save_schema(schema: nil)
12
+ # Create or update the FGA schema.
13
+ # schema (String): the schema DSL string.
14
+ mgmt_post(FGA_SAVE_SCHEMA_PATH, { dsl: schema })
15
+ end
16
+
17
+ def fga_load_schema
18
+ # Load the FGA schema for the project.
19
+ mgmt_get(FGA_LOAD_SCHEMA_PATH)
20
+ end
21
+
22
+ def fga_create_relations(tuples: nil)
23
+ # Create the given relations (tuples) based on the existing schema.
24
+ mgmt_post(FGA_CREATE_RELATIONS_PATH, { tuples: })
25
+ end
26
+
27
+ def fga_delete_relations(tuples: nil)
28
+ # Delete the given relations (tuples) based on the existing schema.
29
+ mgmt_post(FGA_DELETE_RELATIONS_PATH, { tuples: })
30
+ end
31
+
32
+ def fga_check(tuples: nil)
33
+ # Check the given relations (tuples) to see if they are allowed.
34
+ mgmt_post(FGA_CHECK_PATH, { tuples: })
35
+ end
36
+
37
+ def fga_load_mappable_schema(tenant_id: nil, options: nil)
38
+ # Load the mappable schema for the given tenant.
39
+ request_params = { tenantId: tenant_id }
40
+ request_params[:resourcesLimit] = options[:resourcesLimit] if options && options[:resourcesLimit]
41
+ mgmt_get(FGA_LOAD_MAPPABLE_SCHEMA_PATH, request_params)
42
+ end
43
+
44
+ def fga_search_mappable_resources(tenant_id: nil, resources_queries: nil, options: nil)
45
+ # Search for mappable resources for the given tenant.
46
+ request_params = { tenantId: tenant_id, resourcesQueries: resources_queries }
47
+ request_params[:resourcesLimit] = options[:resourcesLimit] if options && options[:resourcesLimit]
48
+ mgmt_post(FGA_SEARCH_MAPPABLE_RESOURCES_PATH, request_params)
49
+ end
50
+
51
+ def fga_load_resources_details(resource_identifiers: nil)
52
+ # Load the details of the given resource identifiers.
53
+ mgmt_post(FGA_RESOURCES_LOAD_PATH, { resourceIdentifiers: resource_identifiers })
54
+ end
55
+
56
+ def fga_save_resources_details(resources_details: nil)
57
+ # Save the details of the given resources.
58
+ mgmt_post(FGA_RESOURCES_SAVE_PATH, { resourcesDetails: resources_details })
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -15,14 +15,14 @@ module Descope
15
15
  # To search for a flow or several flows, send a body with the flowIds you want to search such as { "ids": ["sign-in"] } or { "ids": ["sign-in", "sign-up"] }.
16
16
  def list_or_search_flows(ids = [])
17
17
  request_params = { ids: }
18
- post(FLOW_LIST_PATH, request_params)
18
+ mgmt_post(FLOW_LIST_PATH, request_params)
19
19
  end
20
20
 
21
21
  # Export the given flow id flow and screens.
22
22
  # @see https://docs.descope.com/api/openapi/flowmanagement/operation/ExportFlow/
23
23
  def export_flow(flow_id = nil)
24
24
  request_params = { flowId: flow_id }
25
- post(FLOW_EXPORT_PATH, request_params)
25
+ mgmt_post(FLOW_EXPORT_PATH, request_params)
26
26
  end
27
27
 
28
28
  # Import the given flow and screens.
@@ -33,20 +33,20 @@ module Descope
33
33
  flow:,
34
34
  screens:
35
35
  }
36
- post(FLOW_IMPORT_PATH, request_params)
36
+ mgmt_post(FLOW_IMPORT_PATH, request_params)
37
37
  end
38
38
 
39
39
  # Export the current project theme.
40
40
  # @see https://docs.descope.com/api/openapi/flowmanagement/operation/ExportTheme/
41
41
  def export_theme
42
- post(THEME_EXPORT_PATH)
42
+ mgmt_post(THEME_EXPORT_PATH)
43
43
  end
44
44
 
45
45
  # Import the current project theme.
46
46
  # @see https://docs.descope.com/api/openapi/flowmanagement/operation/ImportTheme/
47
47
  def import_theme(theme)
48
48
  request_params = { theme: }
49
- post(THEME_IMPORT_PATH, request_params)
49
+ mgmt_post(THEME_IMPORT_PATH, request_params)
50
50
  end
51
51
  end
52
52
  end