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.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yaml +4 -4
- data/.github/workflows/publish-gem.yaml +2 -2
- data/.github/workflows/release-please.yaml +1 -1
- data/.release-please-manifest.json +1 -1
- data/.rubocop.yml +1 -1
- data/.rubocop_todo.yml +1 -1
- data/.ruby-version +1 -1
- data/CHANGELOG.md +10 -0
- data/Gemfile +5 -5
- data/Gemfile.lock +32 -32
- data/README.md +233 -1
- data/lib/descope/api/v1/auth/enchantedlink.rb +76 -9
- data/lib/descope/api/v1/management/access_key.rb +8 -7
- data/lib/descope/api/v1/management/analytics.rb +62 -0
- data/lib/descope/api/v1/management/audit.rb +2 -2
- data/lib/descope/api/v1/management/authz.rb +15 -15
- data/lib/descope/api/v1/management/common.rb +76 -0
- data/lib/descope/api/v1/management/descoper.rb +45 -0
- data/lib/descope/api/v1/management/engine.rb +44 -0
- data/lib/descope/api/v1/management/fga.rb +64 -0
- data/lib/descope/api/v1/management/flow.rb +5 -5
- data/lib/descope/api/v1/management/group.rb +42 -0
- data/lib/descope/api/v1/management/jwt_template.rb +49 -0
- data/lib/descope/api/v1/management/lists.rb +96 -0
- data/lib/descope/api/v1/management/management_key.rb +54 -0
- data/lib/descope/api/v1/management/outbound_app.rb +112 -0
- data/lib/descope/api/v1/management/password.rb +2 -2
- data/lib/descope/api/v1/management/permission.rb +4 -4
- data/lib/descope/api/v1/management/project.rb +5 -5
- data/lib/descope/api/v1/management/role.rb +5 -5
- data/lib/descope/api/v1/management/scim.rb +14 -14
- data/lib/descope/api/v1/management/scope_claim_mapping.rb +34 -0
- data/lib/descope/api/v1/management/sso_application.rb +7 -7
- data/lib/descope/api/v1/management/sso_settings.rb +5 -5
- data/lib/descope/api/v1/management/tenant.rb +8 -6
- data/lib/descope/api/v1/management/third_party_application.rb +190 -0
- data/lib/descope/api/v1/management/user.rb +36 -36
- data/lib/descope/api/v1/management.rb +22 -0
- data/lib/descope/http_client.rb +30 -0
- data/lib/descope/mixins/common.rb +1 -0
- data/lib/descope/mixins/http.rb +23 -16
- data/lib/descope/mixins/initializer.rb +19 -9
- data/lib/descope/mixins/requests.rb +24 -0
- data/lib/descope/mixins.rb +2 -1
- data/lib/descope/version.rb +1 -1
- data/spec/integration/lib.descope/api/v1/management/user_spec.rb +1 -1
- data/spec/lib.descope/api/v1/auth/enchantedlink_spec.rb +163 -1
- data/spec/lib.descope/api/v1/management/access_key_spec.rb +7 -7
- data/spec/lib.descope/api/v1/management/analytics_spec.rb +82 -0
- data/spec/lib.descope/api/v1/management/audit_spec.rb +2 -2
- data/spec/lib.descope/api/v1/management/authz_spec.rb +16 -16
- data/spec/lib.descope/api/v1/management/descoper_spec.rb +101 -0
- data/spec/lib.descope/api/v1/management/engine_spec.rb +115 -0
- data/spec/lib.descope/api/v1/management/fga_spec.rb +169 -0
- data/spec/lib.descope/api/v1/management/flow_spec.rb +5 -5
- data/spec/lib.descope/api/v1/management/group_spec.rb +72 -0
- data/spec/lib.descope/api/v1/management/jwt_template_spec.rb +103 -0
- data/spec/lib.descope/api/v1/management/lists_spec.rb +285 -0
- data/spec/lib.descope/api/v1/management/management_key_spec.rb +109 -0
- data/spec/lib.descope/api/v1/management/outbound_app_spec.rb +236 -0
- data/spec/lib.descope/api/v1/management/password_spec.rb +2 -2
- data/spec/lib.descope/api/v1/management/permission_spec.rb +4 -4
- data/spec/lib.descope/api/v1/management/project_spec.rb +4 -4
- data/spec/lib.descope/api/v1/management/role_spec.rb +5 -5
- data/spec/lib.descope/api/v1/management/scim_spec.rb +14 -14
- data/spec/lib.descope/api/v1/management/scope_claim_mapping_spec.rb +59 -0
- data/spec/lib.descope/api/v1/management/sso_application_spec.rb +6 -6
- data/spec/lib.descope/api/v1/management/sso_settings_spec.rb +5 -5
- data/spec/lib.descope/api/v1/management/tenant_spec.rb +6 -6
- data/spec/lib.descope/api/v1/management/third_party_application_spec.rb +171 -0
- data/spec/lib.descope/api/v1/management/user_spec.rb +36 -36
- data/spec/lib.descope/auth_management_key_spec.rb +151 -0
- data/spec/support/client_config.rb +1 -0
- data/spec/support/dummy_class.rb +12 -9
- metadata +28 -3
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Descope
|
|
4
|
+
module Api
|
|
5
|
+
module V1
|
|
6
|
+
module Management
|
|
7
|
+
# Management API calls for SSO groups querying
|
|
8
|
+
module Group
|
|
9
|
+
include Descope::Api::V1::Management::Common
|
|
10
|
+
|
|
11
|
+
def load_all_groups(tenant_id:)
|
|
12
|
+
# Load all groups for a given tenant id.
|
|
13
|
+
mgmt_post(GROUP_LOAD_ALL_PATH, { tenantId: tenant_id })
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def load_all_groups_for_members(tenant_id:, user_ids: nil, login_ids: nil)
|
|
17
|
+
# Load all groups for the given user's or login IDs (can be given either).
|
|
18
|
+
mgmt_post(
|
|
19
|
+
GROUP_LOAD_ALL_FOR_MEMBER_PATH,
|
|
20
|
+
{
|
|
21
|
+
tenantId: tenant_id,
|
|
22
|
+
loginIds: login_ids,
|
|
23
|
+
userIds: user_ids
|
|
24
|
+
}
|
|
25
|
+
)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def load_all_group_members(tenant_id:, group_id:)
|
|
29
|
+
# Load all members of the given group id.
|
|
30
|
+
mgmt_post(
|
|
31
|
+
GROUP_LOAD_ALL_GROUP_MEMBERS_PATH,
|
|
32
|
+
{
|
|
33
|
+
tenantId: tenant_id,
|
|
34
|
+
groupId: group_id
|
|
35
|
+
}
|
|
36
|
+
)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Descope
|
|
4
|
+
module Api
|
|
5
|
+
module V1
|
|
6
|
+
module Management
|
|
7
|
+
# Management API calls for JWT templates
|
|
8
|
+
module JWTTemplate
|
|
9
|
+
include Descope::Api::V1::Management::Common
|
|
10
|
+
|
|
11
|
+
def create_jwt_template(template: nil)
|
|
12
|
+
# Create a new JWT template.
|
|
13
|
+
# Args:
|
|
14
|
+
# template (dict): the JWT template dict with format
|
|
15
|
+
# {
|
|
16
|
+
# "name": "name-of-template",
|
|
17
|
+
# "description": "description of the template",
|
|
18
|
+
# "template": "the template body",
|
|
19
|
+
# "conformanceIssuer": True|False,
|
|
20
|
+
# "authSchema": "one of default|tenantOnly|none"
|
|
21
|
+
# }
|
|
22
|
+
mgmt_post(JWT_TEMPLATE_CREATE_PATH, { template: })
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def update_jwt_template(template: nil)
|
|
26
|
+
# Update an existing JWT template.
|
|
27
|
+
# The given template must include an "id" field.
|
|
28
|
+
mgmt_post(JWT_TEMPLATE_UPDATE_PATH, { template: })
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def delete_jwt_template(id: nil)
|
|
32
|
+
# Delete the JWT template with the given id.
|
|
33
|
+
mgmt_post(JWT_TEMPLATE_DELETE_PATH, { id: })
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def list_jwt_templates
|
|
37
|
+
# Load all JWT templates for the project.
|
|
38
|
+
mgmt_post(JWT_TEMPLATE_LIST_PATH, {})
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def load_jwt_template(id: nil)
|
|
42
|
+
# Load the JWT template with the given id.
|
|
43
|
+
mgmt_post(JWT_TEMPLATE_LOAD_PATH, { id: })
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Descope
|
|
4
|
+
module Api
|
|
5
|
+
module V1
|
|
6
|
+
module Management
|
|
7
|
+
# Management API calls for the deny/allow lists (of IPs and texts)
|
|
8
|
+
module Lists
|
|
9
|
+
include Descope::Api::V1::Management::Common
|
|
10
|
+
|
|
11
|
+
def create_list(name: nil, type: nil, description: nil, data: nil)
|
|
12
|
+
# Create a new list with the given name and type.
|
|
13
|
+
body = { name:, type: }
|
|
14
|
+
body[:description] = description unless description.nil?
|
|
15
|
+
body[:data] = data unless data.nil?
|
|
16
|
+
mgmt_post(LIST_CREATE_PATH, body)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def update_list(id: nil, name: nil, type: nil, description: nil, data: nil)
|
|
20
|
+
# Update an existing list. IMPORTANT: All parameters are used as overrides to the existing list.
|
|
21
|
+
body = { id:, name:, type: }
|
|
22
|
+
body[:description] = description unless description.nil?
|
|
23
|
+
body[:data] = data unless data.nil?
|
|
24
|
+
mgmt_post(LIST_UPDATE_PATH, body)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def delete_list(id: nil)
|
|
28
|
+
# Delete an existing list. IMPORTANT: This action is irreversible. Use carefully.
|
|
29
|
+
mgmt_post(LIST_DELETE_PATH, { id: })
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def load_list(id: nil)
|
|
33
|
+
# Load list by id.
|
|
34
|
+
mgmt_get("#{LIST_LOAD_PATH}/#{id}")
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def load_list_by_name(name: nil)
|
|
38
|
+
# Load list by name.
|
|
39
|
+
mgmt_get("#{LIST_LOAD_BY_NAME_PATH}/#{name}")
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def load_all_lists
|
|
43
|
+
# Load all lists.
|
|
44
|
+
mgmt_get(LIST_LOAD_ALL_PATH)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def import_lists(lists: nil)
|
|
48
|
+
# Import the given lists.
|
|
49
|
+
mgmt_post(LIST_IMPORT_PATH, { lists: })
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def list_add_ips(id: nil, ips: nil)
|
|
53
|
+
# Add the given IPs to the list with the given id.
|
|
54
|
+
mgmt_post(LIST_ADD_IPS_PATH, { id:, ips: })
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def list_remove_ips(id: nil, ips: nil)
|
|
58
|
+
# Remove the given IPs from the list with the given id.
|
|
59
|
+
mgmt_post(LIST_REMOVE_IPS_PATH, { id:, ips: })
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def list_check_ip(id: nil, ip: nil)
|
|
63
|
+
# Check whether the given IP exists in the list with the given id.
|
|
64
|
+
mgmt_post(LIST_CHECK_IP_PATH, { id:, ip: })
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def list_add_texts(id: nil, texts: nil)
|
|
68
|
+
# Add the given texts to the list with the given id.
|
|
69
|
+
mgmt_post(LIST_ADD_TEXTS_PATH, { id:, texts: })
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def list_remove_texts(id: nil, texts: nil)
|
|
73
|
+
# Remove the given texts from the list with the given id.
|
|
74
|
+
mgmt_post(LIST_REMOVE_TEXTS_PATH, { id:, texts: })
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def list_check_text(id: nil, text: nil)
|
|
78
|
+
# Check whether the given text exists in the list with the given id.
|
|
79
|
+
mgmt_post(LIST_CHECK_TEXT_PATH, { id:, text: })
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def list_check_texts(id: nil, texts: nil, match_all: false)
|
|
83
|
+
# Check whether the given texts exist in the list with the given id (up to 100 texts).
|
|
84
|
+
# By default it is enough for any of the texts to exist; set match_all to require all of them.
|
|
85
|
+
mgmt_post(LIST_CHECK_TEXT_PATH, { id:, texts:, matchAll: match_all })
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def clear_list(id: nil)
|
|
89
|
+
# Clear all entries from the list with the given id.
|
|
90
|
+
mgmt_post(LIST_CLEAR_PATH, { id: })
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Descope
|
|
4
|
+
module Api
|
|
5
|
+
module V1
|
|
6
|
+
module Management
|
|
7
|
+
# Management API calls for management keys
|
|
8
|
+
module ManagementKey
|
|
9
|
+
include Descope::Api::V1::Management::Common
|
|
10
|
+
|
|
11
|
+
def create_management_key(name:, description: nil, expires_in: 0, permitted_ips: nil, re_bac: nil)
|
|
12
|
+
# Create a new management key.
|
|
13
|
+
mgmt_put(MGMT_KEY_CREATE_PATH, {
|
|
14
|
+
name:,
|
|
15
|
+
description:,
|
|
16
|
+
expiresIn: expires_in,
|
|
17
|
+
permittedIps: permitted_ips,
|
|
18
|
+
reBac: re_bac
|
|
19
|
+
})
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def update_management_key(id:, name:, description: nil, permitted_ips: nil, status: nil)
|
|
23
|
+
# Update an existing management key.
|
|
24
|
+
mgmt_patch(MGMT_KEY_UPDATE_PATH, {
|
|
25
|
+
id:,
|
|
26
|
+
name:,
|
|
27
|
+
description:,
|
|
28
|
+
permittedIps: permitted_ips,
|
|
29
|
+
status:
|
|
30
|
+
})
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def get_management_key(id:)
|
|
34
|
+
# Load an existing management key.
|
|
35
|
+
mgmt_get(MGMT_KEY_GET_PATH, { id: })
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def delete_management_key(id:)
|
|
39
|
+
# Delete an existing management key.
|
|
40
|
+
mgmt_post(MGMT_KEY_DELETE_PATH, { ids: [id] })
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def search_management_keys(tenant_ids: nil, status: nil)
|
|
44
|
+
# Search all management keys.
|
|
45
|
+
mgmt_get(MGMT_KEY_SEARCH_PATH, {
|
|
46
|
+
tenantIds: tenant_ids,
|
|
47
|
+
status:
|
|
48
|
+
})
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Descope
|
|
4
|
+
module Api
|
|
5
|
+
module V1
|
|
6
|
+
module Management
|
|
7
|
+
# Outbound App Management API calls
|
|
8
|
+
# Manage outbound application tokens for users
|
|
9
|
+
# @see https://docs.descope.com/api/management/outbound-apps/
|
|
10
|
+
module OutboundApp
|
|
11
|
+
include Descope::Mixins::Validation
|
|
12
|
+
include Descope::Api::V1::Management::Common
|
|
13
|
+
|
|
14
|
+
# Outbound App paths
|
|
15
|
+
OUTBOUND_APP_FETCH_USER_TOKEN_PATH = '/v1/mgmt/outbound/app/user/token'
|
|
16
|
+
OUTBOUND_APP_DELETE_USER_TOKENS_PATH = '/v1/mgmt/outbound/user/tokens'
|
|
17
|
+
OUTBOUND_APP_DELETE_TOKEN_BY_ID_PATH = '/v1/mgmt/outbound/token'
|
|
18
|
+
|
|
19
|
+
# Fetch outbound application user token with the specified scopes.
|
|
20
|
+
# @see https://docs.descope.com/api/management/outbound-apps/fetch-outbound-app-user-token
|
|
21
|
+
#
|
|
22
|
+
# @param app_id [String] The outbound application ID
|
|
23
|
+
# @param user_id [String] The user ID to fetch the token for
|
|
24
|
+
# @param scopes [Array<String>] Optional list of scopes for the token
|
|
25
|
+
# @param with_refresh_token [Boolean] Optional flag to include refresh token (default: false)
|
|
26
|
+
# @param force_refresh [Boolean] Optional flag to force token refresh (default: false)
|
|
27
|
+
# @param tenant_id [String] Optional tenant ID
|
|
28
|
+
#
|
|
29
|
+
# @return [Hash] Token information including accessToken, accessTokenExpiry, etc.
|
|
30
|
+
def fetch_outbound_app_user_token(app_id:, user_id:, scopes: nil, with_refresh_token: false, force_refresh: false, tenant_id: nil)
|
|
31
|
+
validate_app_id(app_id)
|
|
32
|
+
validate_user_id(user_id)
|
|
33
|
+
|
|
34
|
+
body = {
|
|
35
|
+
appId: app_id,
|
|
36
|
+
userId: user_id
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
body[:scopes] = scopes if scopes.is_a?(Array) && !scopes.empty?
|
|
40
|
+
body[:tenantId] = tenant_id unless tenant_id.nil? || tenant_id.empty?
|
|
41
|
+
|
|
42
|
+
# Only include options if at least one is true
|
|
43
|
+
if with_refresh_token || force_refresh
|
|
44
|
+
body[:options] = {
|
|
45
|
+
withRefreshToken: with_refresh_token,
|
|
46
|
+
forceRefresh: force_refresh
|
|
47
|
+
}
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
mgmt_post(OUTBOUND_APP_FETCH_USER_TOKEN_PATH, body)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Delete outbound application tokens by appId or userId.
|
|
54
|
+
# At least one of app_id or user_id must be provided.
|
|
55
|
+
# @see https://docs.descope.com/api/management/outbound-apps/delete-outbound-app-user-tokens
|
|
56
|
+
#
|
|
57
|
+
# @param app_id [String] Optional outbound application ID
|
|
58
|
+
# @param user_id [String] Optional user ID
|
|
59
|
+
#
|
|
60
|
+
# @return [void]
|
|
61
|
+
def delete_outbound_app_user_tokens(app_id: nil, user_id: nil)
|
|
62
|
+
if (app_id.nil? || app_id.empty?) && (user_id.nil? || user_id.empty?)
|
|
63
|
+
raise Descope::ArgumentException.new(
|
|
64
|
+
'At least one of app_id or user_id must be provided',
|
|
65
|
+
code: 400
|
|
66
|
+
)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
query_params = {}
|
|
70
|
+
query_params[:appId] = app_id unless app_id.nil? || app_id.empty?
|
|
71
|
+
query_params[:userId] = user_id unless user_id.nil? || user_id.empty?
|
|
72
|
+
|
|
73
|
+
mgmt_delete(OUTBOUND_APP_DELETE_USER_TOKENS_PATH, query_params)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Delete outbound application token by its ID.
|
|
77
|
+
# @see https://docs.descope.com/api/management/outbound-apps/delete-outbound-app-token-by-id
|
|
78
|
+
#
|
|
79
|
+
# @param token_id [String] The token ID to delete
|
|
80
|
+
#
|
|
81
|
+
# @return [void]
|
|
82
|
+
def delete_outbound_app_token_by_id(token_id:)
|
|
83
|
+
validate_token_id(token_id)
|
|
84
|
+
|
|
85
|
+
query_params = { id: token_id }
|
|
86
|
+
mgmt_delete(OUTBOUND_APP_DELETE_TOKEN_BY_ID_PATH, query_params)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
private
|
|
90
|
+
|
|
91
|
+
def validate_app_id(app_id)
|
|
92
|
+
return unless app_id.nil? || app_id.empty?
|
|
93
|
+
|
|
94
|
+
raise Descope::ArgumentException.new(
|
|
95
|
+
'app_id cannot be empty',
|
|
96
|
+
code: 400
|
|
97
|
+
)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def validate_token_id(token_id)
|
|
101
|
+
return unless token_id.nil? || token_id.empty?
|
|
102
|
+
|
|
103
|
+
raise Descope::ArgumentException.new(
|
|
104
|
+
'token_id cannot be empty',
|
|
105
|
+
code: 400
|
|
106
|
+
)
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
end
|
|
@@ -10,7 +10,7 @@ module Descope
|
|
|
10
10
|
|
|
11
11
|
def get_password_settings(tenant_id)
|
|
12
12
|
# Get password settings for the provided tenant id.
|
|
13
|
-
|
|
13
|
+
mgmt_get(PASSWORD_SETTINGS_PATH, { tenantId: tenant_id })
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
def update_password_settings(settings)
|
|
@@ -20,7 +20,7 @@ module Descope
|
|
|
20
20
|
|
|
21
21
|
# Update password settings for the provided tenant id.
|
|
22
22
|
body = compose_settings_body(settings)
|
|
23
|
-
|
|
23
|
+
mgmt_post(PASSWORD_SETTINGS_PATH, body)
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
private
|
|
@@ -17,7 +17,7 @@ module Descope
|
|
|
17
17
|
name:,
|
|
18
18
|
description:
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
mgmt_post(PERMISSION_CREATE_PATH, request_params)
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def update_permission(name: nil, new_name: nil, description: nil)
|
|
@@ -29,17 +29,17 @@ module Descope
|
|
|
29
29
|
newName: new_name,
|
|
30
30
|
description:
|
|
31
31
|
}
|
|
32
|
-
|
|
32
|
+
mgmt_post(PERMISSION_UPDATE_PATH, request_params)
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
def delete_permission(name = nil)
|
|
36
36
|
# Delete an existing permission. IMPORTANT: This action is irreversible. Use carefully.
|
|
37
|
-
|
|
37
|
+
mgmt_post(PERMISSION_DELETE_PATH, { name: })
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
def load_all_permissions
|
|
41
41
|
# Load all permissions.
|
|
42
|
-
|
|
42
|
+
mgmt_get(PERMISSION_LOAD_ALL_PATH)
|
|
43
43
|
end
|
|
44
44
|
end
|
|
45
45
|
end
|
|
@@ -10,7 +10,7 @@ module Descope
|
|
|
10
10
|
|
|
11
11
|
def rename_project(name)
|
|
12
12
|
# Rename a project.
|
|
13
|
-
|
|
13
|
+
mgmt_post(PROJECT_UPDATE_NAME, { name: })
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
def export_project
|
|
@@ -20,7 +20,7 @@ module Descope
|
|
|
20
20
|
# - Users, tenants and access keys are not cloned.
|
|
21
21
|
# - Secrets, keys and tokens are not stripped from the exported data.
|
|
22
22
|
# @returns a HASH containing the exported JSON files payload.
|
|
23
|
-
|
|
23
|
+
mgmt_post(PROJECT_EXPORT_PATH)
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
def import_project(files: nil, excludes: nil)
|
|
@@ -28,12 +28,12 @@ module Descope
|
|
|
28
28
|
# The argument of files should be the output of the export project endpoint
|
|
29
29
|
body = { files: }
|
|
30
30
|
body[:excludes] = excludes unless excludes.nil?
|
|
31
|
-
|
|
31
|
+
mgmt_post(PROJECT_IMPORT_PATH, body)
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
def delete_project
|
|
35
35
|
# Delete the current project. IMPORTANT: This action is irreversible. Use carefully.
|
|
36
|
-
|
|
36
|
+
mgmt_post(PROJECT_DELETE_PATH)
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
def clone_project(name: nil, tag: nil)
|
|
@@ -44,7 +44,7 @@ module Descope
|
|
|
44
44
|
name:,
|
|
45
45
|
tag:
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
mgmt_post(PROJECT_CLONE, request_params)
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
50
|
end
|
|
@@ -17,7 +17,7 @@ module Descope
|
|
|
17
17
|
permissionNames: permission_names,
|
|
18
18
|
tenantId: tenant_id
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
mgmt_post(ROLE_CREATE_PATH, request_params)
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def update_role(name: nil, new_name: nil, description: nil, permission_names: nil, tenant_id: nil)
|
|
@@ -31,7 +31,7 @@ module Descope
|
|
|
31
31
|
permissionNames: permission_names,
|
|
32
32
|
tenantId: tenant_id
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
mgmt_post(ROLE_UPDATE_PATH, request_params)
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
def delete_role(name: nil, tenant_id: nil)
|
|
@@ -40,12 +40,12 @@ module Descope
|
|
|
40
40
|
|
|
41
41
|
request_params = { name: }
|
|
42
42
|
request_params[:tenantId] = tenant_id if tenant_id
|
|
43
|
-
|
|
43
|
+
mgmt_post(ROLE_DELETE_PATH, request_params)
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
def load_all_roles
|
|
47
47
|
# Load all roles.
|
|
48
|
-
|
|
48
|
+
mgmt_get(ROLE_LOAD_ALL_PATH)
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
def search_roles(role_names: nil, tenant_ids: nil, role_name_like: nil, permission_names: nil)
|
|
@@ -55,7 +55,7 @@ module Descope
|
|
|
55
55
|
request_params[:tenantIds] = tenant_ids if tenant_ids
|
|
56
56
|
request_params[:roleNameLike] = role_name_like if role_name_like
|
|
57
57
|
request_params[:permissionNames] = permission_names if permission_names
|
|
58
|
-
|
|
58
|
+
mgmt_post(ROLE_SEARCH_PATH, request_params)
|
|
59
59
|
end
|
|
60
60
|
end
|
|
61
61
|
end
|
|
@@ -11,21 +11,21 @@ module Descope
|
|
|
11
11
|
def scim_search_groups(filter: nil, start_index: nil, count: nil, excluded_attributes: nil)
|
|
12
12
|
# Search SCIM Groups
|
|
13
13
|
url = compose_scim_search_groups_url(filter, start_index, count, excluded_attributes)
|
|
14
|
-
|
|
14
|
+
mgmt_get(url)
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def scim_create_group(group_id: nil, display_name: nil, members: nil, external_id: nil,
|
|
18
18
|
excluded_attributes: nil)
|
|
19
19
|
# Create SCIM Group
|
|
20
20
|
body = compose_scim_create_group_body(group_id, display_name, members, external_id, excluded_attributes)
|
|
21
|
-
|
|
21
|
+
mgmt_post(SCIM_GROUPS_PATH, body)
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def scim_load_group(group_id: nil, display_name: nil, external_id: nil, excluded_attributes: nil)
|
|
25
25
|
# Load SCIM Group, using a valid access key.
|
|
26
26
|
validate_scim_group_id(group_id)
|
|
27
27
|
url = compose_scim_create_group_url(group_id, display_name, external_id, excluded_attributes)
|
|
28
|
-
|
|
28
|
+
mgmt_get(url)
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
def scim_update_group(group_id: nil, display_name: nil, members: nil, external_id: nil,
|
|
@@ -33,38 +33,38 @@ module Descope
|
|
|
33
33
|
# Update SCIM Group, using a valid access key.
|
|
34
34
|
validate_scim_group_id(group_id)
|
|
35
35
|
body = compose_scim_update_group_body(group_id, display_name, members, external_id, excluded_attributes)
|
|
36
|
-
|
|
36
|
+
mgmt_patch("#{SCIM_GROUPS_PATH}/#{group_id}", body)
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
def scim_delete_group(group_id)
|
|
40
40
|
# Delete SCIM Group, using a valid access key.
|
|
41
41
|
validate_scim_group_id(group_id)
|
|
42
42
|
url = "#{SCIM_GROUPS_PATH}/#{group_id}"
|
|
43
|
-
|
|
43
|
+
mgmt_delete(url)
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
def scim_patch_group(group_id: nil, user_id: nil, operations: nil)
|
|
47
47
|
# Patch SCIM Group, using a valid access key.
|
|
48
48
|
validate_scim_group_id(group_id)
|
|
49
49
|
url = compose_scim_patch_group_url(group_id, user_id, operations)
|
|
50
|
-
|
|
50
|
+
mgmt_patch(url)
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
# SCIM Users
|
|
54
54
|
def scim_load_resource_types
|
|
55
55
|
# Load SCIM Resource Types, using a valid access key.
|
|
56
|
-
|
|
56
|
+
mgmt_get(SCIM_RESOURCE_TYPES_PATH)
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
def scim_load_service_provider_config
|
|
60
60
|
# Load SCIM Service Provider Config, using a valid access key.
|
|
61
|
-
|
|
61
|
+
mgmt_get(SCIM_SERVICE_PROVIDER_CONFIG_PATH)
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
def scim_search_users(filter: nil, start_index: nil, count: nil)
|
|
65
65
|
# Search SCIM Users, using a valid access key.
|
|
66
66
|
url = compose_scim_search_users_url(filter, start_index, count)
|
|
67
|
-
|
|
67
|
+
mgmt_get(url)
|
|
68
68
|
end
|
|
69
69
|
|
|
70
70
|
def scim_create_user(user_id: nil, display_name: nil, emails: nil,
|
|
@@ -72,28 +72,28 @@ module Descope
|
|
|
72
72
|
# Create SCIM User, using a valid access key.
|
|
73
73
|
validate_user_id(user_id)
|
|
74
74
|
body = compose_scim_create_user_body(user_id, display_name, emails, phone_numbers, active, name, user_name)
|
|
75
|
-
|
|
75
|
+
mgmt_post(SCIM_USERS_PATH, body)
|
|
76
76
|
end
|
|
77
77
|
|
|
78
78
|
def scim_load_user(user_id)
|
|
79
79
|
# Load SCIM User, using a valid access key.
|
|
80
80
|
validate_user_id(user_id)
|
|
81
81
|
url = "#{SCIM_USERS_PATH}/#{user_id}"
|
|
82
|
-
|
|
82
|
+
mgmt_get(url)
|
|
83
83
|
end
|
|
84
84
|
|
|
85
85
|
def scim_update_user(user_id)
|
|
86
86
|
# Update SCIM User, using a valid access key.
|
|
87
87
|
validate_user_id(user_id)
|
|
88
88
|
url = "#{SCIM_USERS_PATH}/#{user_id}"
|
|
89
|
-
|
|
89
|
+
mgmt_patch(url)
|
|
90
90
|
end
|
|
91
91
|
|
|
92
92
|
def scim_delete_user(user_id)
|
|
93
93
|
# Delete SCIM User, using a valid access key.
|
|
94
94
|
validate_user_id(user_id)
|
|
95
95
|
url = "#{SCIM_USERS_PATH}/#{user_id}"
|
|
96
|
-
|
|
96
|
+
mgmt_delete(url)
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
def scim_patch_user(user_id: nil, group_id: nil, operations: nil)
|
|
@@ -101,7 +101,7 @@ module Descope
|
|
|
101
101
|
validate_user_id(user_id)
|
|
102
102
|
validate_scim_group_id(group_id)
|
|
103
103
|
body = compose_scim_patch_user_body(user_id, group_id, operations)
|
|
104
|
-
|
|
104
|
+
mgmt_patch(SCIM_USERS_PATH, body)
|
|
105
105
|
end
|
|
106
106
|
|
|
107
107
|
private
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Descope
|
|
4
|
+
module Api
|
|
5
|
+
module V1
|
|
6
|
+
module Management
|
|
7
|
+
# Manage project-wide OIDC scope-to-claim mapping
|
|
8
|
+
module ScopeClaimMapping
|
|
9
|
+
include Descope::Api::V1::Management::Common
|
|
10
|
+
|
|
11
|
+
def get_scope_claim_mapping # rubocop:disable Naming/AccessorMethodName
|
|
12
|
+
# Get the project-wide OIDC scope-to-claim mappings.
|
|
13
|
+
mgmt_post(SCOPE_CLAIM_MAPPING_GET_PATH)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def set_scope_claim_mapping(mappings: nil)
|
|
17
|
+
# Set the project-wide OIDC scope-to-claim mappings.
|
|
18
|
+
# mappings (Array[]): the scope-to-claim mappings to set. Each in the following format:
|
|
19
|
+
# {
|
|
20
|
+
# "scope": "name of the OIDC scope",
|
|
21
|
+
# "claims": ["list of claims mapped to the scope"]
|
|
22
|
+
# }
|
|
23
|
+
mgmt_post(SCOPE_CLAIM_MAPPING_SET_PATH, { mappings: })
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def delete_scope_claim_mapping
|
|
27
|
+
# Delete the project-wide OIDC scope-to-claim mappings.
|
|
28
|
+
mgmt_post(SCOPE_CLAIM_MAPPING_DELETE_PATH)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|