oktakit 0.3.3 → 1.1.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/dependabot.yml +6 -0
- data/.github/workflows/ci.yml +5 -5
- data/.github/workflows/cla.yml +22 -0
- data/.github/workflows/release.yml +70 -0
- data/.rubocop.yml +0 -1
- data/.ruby-version +1 -1
- data/Gemfile +1 -0
- data/Gemfile.lock +75 -69
- data/README.md +5 -1
- data/dev.yml +1 -1
- data/lib/oktakit/client/admin_roles.rb +13 -9
- data/lib/oktakit/client/apps.rb +28 -21
- data/lib/oktakit/client/factors.rb +14 -13
- data/lib/oktakit/client/group_rules.rb +5 -5
- data/lib/oktakit/client/groups.rb +7 -7
- data/lib/oktakit/client/identity_providers.rb +13 -13
- data/lib/oktakit/client/schemas.rb +4 -4
- data/lib/oktakit/client/templates.rb +4 -4
- data/lib/oktakit/client/users.rb +20 -20
- data/lib/oktakit/client.rb +52 -5
- data/lib/oktakit/response/raise_error.rb +1 -1
- data/lib/oktakit/version.rb +1 -1
- data/oktakit.gemspec +6 -4
- metadata +15 -19
- data/.github/probots.yml +0 -2
- data/CHANGELOG.md +0 -19
|
@@ -15,7 +15,7 @@ module Oktakit
|
|
|
15
15
|
# @example
|
|
16
16
|
# Oktakit.get_factor('user_id', 'factor_id')
|
|
17
17
|
def get_factor(user_id, factor_id, options = {})
|
|
18
|
-
get("/users/#{user_id}/factors/#{factor_id}", options)
|
|
18
|
+
get("/users/#{path_segment(user_id)}/factors/#{path_segment(factor_id)}", options)
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
# List Enrolled Factors
|
|
@@ -31,7 +31,7 @@ module Oktakit
|
|
|
31
31
|
# @example
|
|
32
32
|
# Oktakit.list_enrolled_factors('user_id')
|
|
33
33
|
def list_enrolled_factors(user_id, options = {})
|
|
34
|
-
get("/users/#{user_id}/factors", options)
|
|
34
|
+
get("/users/#{path_segment(user_id)}/factors", options)
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
# List Factors to Enroll
|
|
@@ -47,7 +47,7 @@ module Oktakit
|
|
|
47
47
|
# @example
|
|
48
48
|
# Oktakit.list_factors_to_enroll('user_id')
|
|
49
49
|
def list_factors_to_enroll(user_id, options = {})
|
|
50
|
-
get("/users/#{user_id}/factors/catalog", options)
|
|
50
|
+
get("/users/#{path_segment(user_id)}/factors/catalog", options)
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
# List Security Questions
|
|
@@ -63,7 +63,7 @@ module Oktakit
|
|
|
63
63
|
# @example
|
|
64
64
|
# Oktakit.list_security_questions('user_id')
|
|
65
65
|
def list_security_questions(user_id, options = {})
|
|
66
|
-
get("/users/#{user_id}/factors/questions", options)
|
|
66
|
+
get("/users/#{path_segment(user_id)}/factors/questions", options)
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
# Enroll Factor
|
|
@@ -79,7 +79,7 @@ module Oktakit
|
|
|
79
79
|
# @example
|
|
80
80
|
# Oktakit.enroll_factor('id')
|
|
81
81
|
def enroll_factor(user_id, options = {})
|
|
82
|
-
post("/users/#{user_id}/factors", options)
|
|
82
|
+
post("/users/#{path_segment(user_id)}/factors", options)
|
|
83
83
|
end
|
|
84
84
|
|
|
85
85
|
# Activate Factor
|
|
@@ -96,7 +96,7 @@ module Oktakit
|
|
|
96
96
|
# @example
|
|
97
97
|
# Oktakit.activate_factor('user_id', 'factor_id')
|
|
98
98
|
def activate_factor(user_id, factor_id, options = {})
|
|
99
|
-
post("/users/#{user_id}/factors/#{factor_id}/lifecycle/activate", options)
|
|
99
|
+
post("/users/#{path_segment(user_id)}/factors/#{path_segment(factor_id)}/lifecycle/activate", options)
|
|
100
100
|
end
|
|
101
101
|
|
|
102
102
|
# Reset Factor
|
|
@@ -113,7 +113,7 @@ module Oktakit
|
|
|
113
113
|
# @example
|
|
114
114
|
# Oktakit.reset_factor('user_id', 'factor_id')
|
|
115
115
|
def reset_factor(user_id, factor_id, options = {})
|
|
116
|
-
delete("/users/#{user_id}/factors/#{factor_id}", options)
|
|
116
|
+
delete("/users/#{path_segment(user_id)}/factors/#{path_segment(factor_id)}", options)
|
|
117
117
|
end
|
|
118
118
|
|
|
119
119
|
# Verify Security Question Factor
|
|
@@ -130,7 +130,7 @@ module Oktakit
|
|
|
130
130
|
# @example
|
|
131
131
|
# Oktakit.verify_security_question_factor('user_id', 'factor_id')
|
|
132
132
|
def verify_security_question_factor(user_id, factor_id, options = {})
|
|
133
|
-
post("/users/#{user_id}/factors/#{factor_id}/verify", options)
|
|
133
|
+
post("/users/#{path_segment(user_id)}/factors/#{path_segment(factor_id)}/verify", options)
|
|
134
134
|
end
|
|
135
135
|
|
|
136
136
|
# Verify SMS Factor
|
|
@@ -147,7 +147,7 @@ module Oktakit
|
|
|
147
147
|
# @example
|
|
148
148
|
# Oktakit.verify_sms_factor('user_id', 'factor_id')
|
|
149
149
|
def verify_sms_factor(user_id, factor_id, options = {})
|
|
150
|
-
post("/users/#{user_id}/factors/#{factor_id}/verify", options)
|
|
150
|
+
post("/users/#{path_segment(user_id)}/factors/#{path_segment(factor_id)}/verify", options)
|
|
151
151
|
end
|
|
152
152
|
|
|
153
153
|
# Verify TOTP Factor
|
|
@@ -164,7 +164,7 @@ module Oktakit
|
|
|
164
164
|
# @example
|
|
165
165
|
# Oktakit.verify_totp_factor('user_id', 'factor_id')
|
|
166
166
|
def verify_totp_factor(user_id, factor_id, options = {})
|
|
167
|
-
post("/users/#{user_id}/factors/#{factor_id}/verify", options)
|
|
167
|
+
post("/users/#{path_segment(user_id)}/factors/#{path_segment(factor_id)}/verify", options)
|
|
168
168
|
end
|
|
169
169
|
|
|
170
170
|
# Verify Push Factor
|
|
@@ -181,7 +181,7 @@ module Oktakit
|
|
|
181
181
|
# @example
|
|
182
182
|
# Oktakit.verify_push_factor('user_id', 'factor_id')
|
|
183
183
|
def verify_push_factor(user_id, factor_id, options = {})
|
|
184
|
-
post("/users/#{user_id}/factors/#{factor_id}/verify", options)
|
|
184
|
+
post("/users/#{path_segment(user_id)}/factors/#{path_segment(factor_id)}/verify", options)
|
|
185
185
|
end
|
|
186
186
|
|
|
187
187
|
# Poll for Verify Transaction Completion
|
|
@@ -199,7 +199,8 @@ module Oktakit
|
|
|
199
199
|
# @example
|
|
200
200
|
# Oktakit.poll_for_verify_transaction_completion('user_id', 'factor_id', 'transaction_id')
|
|
201
201
|
def poll_for_verify_transaction_completion(user_id, factor_id, transaction_id, options = {})
|
|
202
|
-
|
|
202
|
+
factor = "/users/#{path_segment(user_id)}/factors/#{path_segment(factor_id)}"
|
|
203
|
+
get("#{factor}/transactions/#{path_segment(transaction_id)}", options)
|
|
203
204
|
end
|
|
204
205
|
|
|
205
206
|
# Verify Token Factor
|
|
@@ -216,7 +217,7 @@ module Oktakit
|
|
|
216
217
|
# @example
|
|
217
218
|
# Oktakit.verify_token_factor('user_id', 'factor_id')
|
|
218
219
|
def verify_token_factor(user_id, factor_id, options = {})
|
|
219
|
-
post("/users/#{user_id}/factors/#{factor_id}/verify", options)
|
|
220
|
+
post("/users/#{path_segment(user_id)}/factors/#{path_segment(factor_id)}/verify", options)
|
|
220
221
|
end
|
|
221
222
|
end
|
|
222
223
|
end
|
|
@@ -29,7 +29,7 @@ module Oktakit
|
|
|
29
29
|
# @example
|
|
30
30
|
# Oktakit.get_group_rule('id')
|
|
31
31
|
def get_group_rule(id, options = {})
|
|
32
|
-
get("/groups/rules/#{id}", options)
|
|
32
|
+
get("/groups/rules/#{path_segment(id)}", options)
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
# List Group Rules
|
|
@@ -60,7 +60,7 @@ module Oktakit
|
|
|
60
60
|
# @example
|
|
61
61
|
# Oktakit.update_group_rule('id')
|
|
62
62
|
def update_group_rule(id, options = {})
|
|
63
|
-
put("/groups/rules/#{id}", options)
|
|
63
|
+
put("/groups/rules/#{path_segment(id)}", options)
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
# Remove Group Rule
|
|
@@ -76,7 +76,7 @@ module Oktakit
|
|
|
76
76
|
# @example
|
|
77
77
|
# Oktakit.remove_group_rule('id')
|
|
78
78
|
def remove_group_rule(id, options = {})
|
|
79
|
-
delete("/groups/rules/#{id}", options)
|
|
79
|
+
delete("/groups/rules/#{path_segment(id)}", options)
|
|
80
80
|
end
|
|
81
81
|
|
|
82
82
|
# Activate Group Rule
|
|
@@ -92,7 +92,7 @@ module Oktakit
|
|
|
92
92
|
# @example
|
|
93
93
|
# Oktakit.activate_group_rule('id')
|
|
94
94
|
def activate_group_rule(id, options = {})
|
|
95
|
-
post("/groups/rules/#{id}/lifecycle/activate", options)
|
|
95
|
+
post("/groups/rules/#{path_segment(id)}/lifecycle/activate", options)
|
|
96
96
|
end
|
|
97
97
|
|
|
98
98
|
# Deactivate Group Rule
|
|
@@ -108,7 +108,7 @@ module Oktakit
|
|
|
108
108
|
# @example
|
|
109
109
|
# Oktakit.deactivate_group_rule('id')
|
|
110
110
|
def deactivate_group_rule(id, options = {})
|
|
111
|
-
post("/groups/rules/#{id}/lifecycle/deactivate", options)
|
|
111
|
+
post("/groups/rules/#{path_segment(id)}/lifecycle/deactivate", options)
|
|
112
112
|
end
|
|
113
113
|
end
|
|
114
114
|
end
|
|
@@ -29,7 +29,7 @@ module Oktakit
|
|
|
29
29
|
# @example
|
|
30
30
|
# Oktakit.get_group('id')
|
|
31
31
|
def get_group(id, options = {})
|
|
32
|
-
get("/groups/#{id}", options)
|
|
32
|
+
get("/groups/#{path_segment(id)}", options)
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
# List Groups
|
|
@@ -60,7 +60,7 @@ module Oktakit
|
|
|
60
60
|
# @example
|
|
61
61
|
# Oktakit.update_group('id')
|
|
62
62
|
def update_group(id, options = {})
|
|
63
|
-
put("/groups/#{id}", options)
|
|
63
|
+
put("/groups/#{path_segment(id)}", options)
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
# Remove Group
|
|
@@ -76,7 +76,7 @@ module Oktakit
|
|
|
76
76
|
# @example
|
|
77
77
|
# Oktakit.remove_group('id')
|
|
78
78
|
def remove_group(id, options = {})
|
|
79
|
-
delete("/groups/#{id}", options)
|
|
79
|
+
delete("/groups/#{path_segment(id)}", options)
|
|
80
80
|
end
|
|
81
81
|
|
|
82
82
|
# List Group Members
|
|
@@ -92,7 +92,7 @@ module Oktakit
|
|
|
92
92
|
# @example
|
|
93
93
|
# Oktakit.list_group_members('id')
|
|
94
94
|
def list_group_members(id, options = {})
|
|
95
|
-
get("/groups/#{id}/users", options)
|
|
95
|
+
get("/groups/#{path_segment(id)}/users", options)
|
|
96
96
|
end
|
|
97
97
|
|
|
98
98
|
# Add User to Group
|
|
@@ -109,7 +109,7 @@ module Oktakit
|
|
|
109
109
|
# @example
|
|
110
110
|
# Oktakit.add_user_to_group('group_id', 'user_id')
|
|
111
111
|
def add_user_to_group(group_id, user_id, options = {})
|
|
112
|
-
put("/groups/#{group_id}/users/#{user_id}", options)
|
|
112
|
+
put("/groups/#{path_segment(group_id)}/users/#{path_segment(user_id)}", options)
|
|
113
113
|
end
|
|
114
114
|
|
|
115
115
|
# Remove User from Group
|
|
@@ -126,7 +126,7 @@ module Oktakit
|
|
|
126
126
|
# @example
|
|
127
127
|
# Oktakit.remove_user_from_group('group_id', 'user_id')
|
|
128
128
|
def remove_user_from_group(group_id, user_id, options = {})
|
|
129
|
-
delete("/groups/#{group_id}/users/#{user_id}", options)
|
|
129
|
+
delete("/groups/#{path_segment(group_id)}/users/#{path_segment(user_id)}", options)
|
|
130
130
|
end
|
|
131
131
|
|
|
132
132
|
# List Assigned Applications
|
|
@@ -142,7 +142,7 @@ module Oktakit
|
|
|
142
142
|
# @example
|
|
143
143
|
# Oktakit.list_assigned_applications('id')
|
|
144
144
|
def list_assigned_applications(id, options = {})
|
|
145
|
-
get("/groups/#{id}/apps", options)
|
|
145
|
+
get("/groups/#{path_segment(id)}/apps", options)
|
|
146
146
|
end
|
|
147
147
|
end
|
|
148
148
|
end
|
|
@@ -29,7 +29,7 @@ module Oktakit
|
|
|
29
29
|
# @example
|
|
30
30
|
# Oktakit.get_identity_provider('id')
|
|
31
31
|
def get_identity_provider(id, options = {})
|
|
32
|
-
get("/idps/#{id}", options)
|
|
32
|
+
get("/idps/#{path_segment(id)}", options)
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
# List Identity Providers
|
|
@@ -60,7 +60,7 @@ module Oktakit
|
|
|
60
60
|
# @example
|
|
61
61
|
# Oktakit.update_identity_provider('id')
|
|
62
62
|
def update_identity_provider(id, options = {})
|
|
63
|
-
put("/idps/#{id}", options)
|
|
63
|
+
put("/idps/#{path_segment(id)}", options)
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
# Delete Identity Provider
|
|
@@ -76,7 +76,7 @@ module Oktakit
|
|
|
76
76
|
# @example
|
|
77
77
|
# Oktakit.delete_identity_provider('id')
|
|
78
78
|
def delete_identity_provider(id, options = {})
|
|
79
|
-
delete("/idps/#{id}", options)
|
|
79
|
+
delete("/idps/#{path_segment(id)}", options)
|
|
80
80
|
end
|
|
81
81
|
|
|
82
82
|
# Activate Identity Provider
|
|
@@ -92,7 +92,7 @@ module Oktakit
|
|
|
92
92
|
# @example
|
|
93
93
|
# Oktakit.activate_identity_provider('id')
|
|
94
94
|
def activate_identity_provider(id, options = {})
|
|
95
|
-
post("/idps/#{id}/lifecycle/activate", options)
|
|
95
|
+
post("/idps/#{path_segment(id)}/lifecycle/activate", options)
|
|
96
96
|
end
|
|
97
97
|
|
|
98
98
|
# Deactivate Identity Provider
|
|
@@ -108,7 +108,7 @@ module Oktakit
|
|
|
108
108
|
# @example
|
|
109
109
|
# Oktakit.deactivate_identity_provider('id')
|
|
110
110
|
def deactivate_identity_provider(id, options = {})
|
|
111
|
-
post("/idps/#{id}/lifecycle/deactivate", options)
|
|
111
|
+
post("/idps/#{path_segment(id)}/lifecycle/deactivate", options)
|
|
112
112
|
end
|
|
113
113
|
|
|
114
114
|
# Get Identity Provider Transaction
|
|
@@ -124,7 +124,7 @@ module Oktakit
|
|
|
124
124
|
# @example
|
|
125
125
|
# Oktakit.get_identity_provider_transaction('transaction_id')
|
|
126
126
|
def get_identity_provider_transaction(transaction_id, options = {})
|
|
127
|
-
get("/idps/tx/#{transaction_id}", options)
|
|
127
|
+
get("/idps/tx/#{path_segment(transaction_id)}", options)
|
|
128
128
|
end
|
|
129
129
|
|
|
130
130
|
# Get Source IdP User for IdP Transaction
|
|
@@ -140,7 +140,7 @@ module Oktakit
|
|
|
140
140
|
# @example
|
|
141
141
|
# Oktakit.get_source_idp_user_for_idp_transaction('transaction_id')
|
|
142
142
|
def get_source_idp_user_for_idp_transaction(transaction_id, options = {})
|
|
143
|
-
get("/idps/tx/#{transaction_id}/source", options)
|
|
143
|
+
get("/idps/tx/#{path_segment(transaction_id)}/source", options)
|
|
144
144
|
end
|
|
145
145
|
|
|
146
146
|
# Get Target User for IdP Provision Transaction
|
|
@@ -156,7 +156,7 @@ module Oktakit
|
|
|
156
156
|
# @example
|
|
157
157
|
# Oktakit.get_target_user_for_idp_provision_transaction('transaction_id')
|
|
158
158
|
def get_target_user_for_idp_provision_transaction(transaction_id, options = {})
|
|
159
|
-
get("/idps/tx/#{transaction_id}/target", options)
|
|
159
|
+
get("/idps/tx/#{path_segment(transaction_id)}/target", options)
|
|
160
160
|
end
|
|
161
161
|
|
|
162
162
|
# List Users for IdP Link Transaction
|
|
@@ -172,7 +172,7 @@ module Oktakit
|
|
|
172
172
|
# @example
|
|
173
173
|
# Oktakit.list_users_for_idp_link_transaction('transaction_id')
|
|
174
174
|
def list_users_for_idp_link_transaction(transaction_id, options = {})
|
|
175
|
-
get("/idps/tx/#{transaction_id}/users", options)
|
|
175
|
+
get("/idps/tx/#{path_segment(transaction_id)}/users", options)
|
|
176
176
|
end
|
|
177
177
|
|
|
178
178
|
# Provision IdP User
|
|
@@ -188,7 +188,7 @@ module Oktakit
|
|
|
188
188
|
# @example
|
|
189
189
|
# Oktakit.provision_idp_user('transaction_id')
|
|
190
190
|
def provision_idp_user(transaction_id, options = {})
|
|
191
|
-
post("/idps/tx/#{transaction_id}/lifecycle/provision", options)
|
|
191
|
+
post("/idps/tx/#{path_segment(transaction_id)}/lifecycle/provision", options)
|
|
192
192
|
end
|
|
193
193
|
|
|
194
194
|
# Link IdP User
|
|
@@ -205,7 +205,7 @@ module Oktakit
|
|
|
205
205
|
# @example
|
|
206
206
|
# Oktakit.link_idp_user('user_id', 'transaction_id')
|
|
207
207
|
def link_idp_user(transaction_id, user_id, options = {})
|
|
208
|
-
post("/idps/tx/#{transaction_id}/lifecycle/confirm/#{user_id}", options)
|
|
208
|
+
post("/idps/tx/#{path_segment(transaction_id)}/lifecycle/confirm/#{path_segment(user_id)}", options)
|
|
209
209
|
end
|
|
210
210
|
|
|
211
211
|
# Add X.509 Certificate Public Key
|
|
@@ -236,7 +236,7 @@ module Oktakit
|
|
|
236
236
|
# @example
|
|
237
237
|
# Oktakit.get_key('key_id')
|
|
238
238
|
def get_key(key_id, options = {})
|
|
239
|
-
get("/idps/credentials/keys/#{key_id}", options)
|
|
239
|
+
get("/idps/credentials/keys/#{path_segment(key_id)}", options)
|
|
240
240
|
end
|
|
241
241
|
|
|
242
242
|
# List Keys
|
|
@@ -267,7 +267,7 @@ module Oktakit
|
|
|
267
267
|
# @example
|
|
268
268
|
# Oktakit.delete_key('key_id')
|
|
269
269
|
def delete_key(key_id, options = {})
|
|
270
|
-
delete("/idps/credentials/keys/#{key_id}", options)
|
|
270
|
+
delete("/idps/credentials/keys/#{path_segment(key_id)}", options)
|
|
271
271
|
end
|
|
272
272
|
end
|
|
273
273
|
end
|
|
@@ -74,7 +74,7 @@ module Oktakit
|
|
|
74
74
|
# @example
|
|
75
75
|
# Oktakit.get_app_user_schema('id')
|
|
76
76
|
def get_app_user_schema(id, options = {})
|
|
77
|
-
get("/meta/schemas/apps/#{id}/default", options)
|
|
77
|
+
get("/meta/schemas/apps/#{path_segment(id)}/default", options)
|
|
78
78
|
end
|
|
79
79
|
|
|
80
80
|
# Add Property to App User Profile Schema
|
|
@@ -90,7 +90,7 @@ module Oktakit
|
|
|
90
90
|
# @example
|
|
91
91
|
# Oktakit.add_property_to_app_user_profile_schema('id')
|
|
92
92
|
def add_property_to_app_user_profile_schema(id, options = {})
|
|
93
|
-
post("/meta/schemas/apps/#{id}/default", options)
|
|
93
|
+
post("/meta/schemas/apps/#{path_segment(id)}/default", options)
|
|
94
94
|
end
|
|
95
95
|
|
|
96
96
|
# Update App User Profile Schema property
|
|
@@ -106,7 +106,7 @@ module Oktakit
|
|
|
106
106
|
# @example
|
|
107
107
|
# Oktakit.update_app_user_profile_schema_property('id')
|
|
108
108
|
def update_app_user_profile_schema_property(id, options = {})
|
|
109
|
-
post("/meta/schemas/apps/#{id}/default", options)
|
|
109
|
+
post("/meta/schemas/apps/#{path_segment(id)}/default", options)
|
|
110
110
|
end
|
|
111
111
|
|
|
112
112
|
# Remove property from App User Profile Schema
|
|
@@ -122,7 +122,7 @@ module Oktakit
|
|
|
122
122
|
# @example
|
|
123
123
|
# Oktakit.remove_property_from_app_user_profile_schema('id')
|
|
124
124
|
def remove_property_from_app_user_profile_schema(id, options = {})
|
|
125
|
-
post("/meta/schemas/apps/#{id}/default", options)
|
|
125
|
+
post("/meta/schemas/apps/#{path_segment(id)}/default", options)
|
|
126
126
|
end
|
|
127
127
|
end
|
|
128
128
|
end
|
|
@@ -29,7 +29,7 @@ module Oktakit
|
|
|
29
29
|
# @example
|
|
30
30
|
# Oktakit.get_sms_template('id')
|
|
31
31
|
def get_sms_template(id, options = {})
|
|
32
|
-
get("/templates/sms/#{id}", options)
|
|
32
|
+
get("/templates/sms/#{path_segment(id)}", options)
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
# List SMS Templates
|
|
@@ -60,7 +60,7 @@ module Oktakit
|
|
|
60
60
|
# @example
|
|
61
61
|
# Oktakit.update_sms_template('id')
|
|
62
62
|
def update_sms_template(id, options = {})
|
|
63
|
-
put("/templates/sms/#{id}", options)
|
|
63
|
+
put("/templates/sms/#{path_segment(id)}", options)
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
# Partial SMS Template Update
|
|
@@ -76,7 +76,7 @@ module Oktakit
|
|
|
76
76
|
# @example
|
|
77
77
|
# Oktakit.partial_sms_template_update('id')
|
|
78
78
|
def partial_sms_template_update(id, options = {})
|
|
79
|
-
post("/templates/sms/#{id}", options)
|
|
79
|
+
post("/templates/sms/#{path_segment(id)}", options)
|
|
80
80
|
end
|
|
81
81
|
|
|
82
82
|
# Remove SMS Template
|
|
@@ -92,7 +92,7 @@ module Oktakit
|
|
|
92
92
|
# @example
|
|
93
93
|
# Oktakit.remove_sms_template('id')
|
|
94
94
|
def remove_sms_template(id, options = {})
|
|
95
|
-
delete("/templates/sms/#{id}", options)
|
|
95
|
+
delete("/templates/sms/#{path_segment(id)}", options)
|
|
96
96
|
end
|
|
97
97
|
end
|
|
98
98
|
end
|
data/lib/oktakit/client/users.rb
CHANGED
|
@@ -29,7 +29,7 @@ module Oktakit
|
|
|
29
29
|
# @example
|
|
30
30
|
# Oktakit.get_user('id')
|
|
31
31
|
def get_user(id, options = {})
|
|
32
|
-
get("/users/#{id}", options)
|
|
32
|
+
get("/users/#{path_segment(id)}", options)
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
# List Users
|
|
@@ -62,9 +62,9 @@ module Oktakit
|
|
|
62
62
|
# Oktakit.update_user('id')
|
|
63
63
|
def update_user(id, options = {})
|
|
64
64
|
if options.delete(:partial)
|
|
65
|
-
post("/users/#{id}", options)
|
|
65
|
+
post("/users/#{path_segment(id)}", options)
|
|
66
66
|
else
|
|
67
|
-
put("/users/#{id}", options)
|
|
67
|
+
put("/users/#{path_segment(id)}", options)
|
|
68
68
|
end
|
|
69
69
|
end
|
|
70
70
|
|
|
@@ -81,7 +81,7 @@ module Oktakit
|
|
|
81
81
|
# @example
|
|
82
82
|
# Oktakit.update_profile('id')
|
|
83
83
|
def update_profile(id, options = {})
|
|
84
|
-
post("/users/#{id}", options)
|
|
84
|
+
post("/users/#{path_segment(id)}", options)
|
|
85
85
|
end
|
|
86
86
|
|
|
87
87
|
# Get Assigned App Links
|
|
@@ -96,7 +96,7 @@ module Oktakit
|
|
|
96
96
|
# @example
|
|
97
97
|
# Oktakit.get_assigned_app_links('id')
|
|
98
98
|
def get_assigned_app_links(id, options = {})
|
|
99
|
-
get("/users/#{id}/appLinks", options)
|
|
99
|
+
get("/users/#{path_segment(id)}/appLinks", options)
|
|
100
100
|
end
|
|
101
101
|
|
|
102
102
|
# Get Member Groups
|
|
@@ -112,7 +112,7 @@ module Oktakit
|
|
|
112
112
|
# @example
|
|
113
113
|
# Oktakit.get_member_groups('id')
|
|
114
114
|
def get_member_groups(id, options = {})
|
|
115
|
-
get("/users/#{id}/groups", options)
|
|
115
|
+
get("/users/#{path_segment(id)}/groups", options)
|
|
116
116
|
end
|
|
117
117
|
|
|
118
118
|
# Activate User
|
|
@@ -128,7 +128,7 @@ module Oktakit
|
|
|
128
128
|
# @example
|
|
129
129
|
# Oktakit.activate_user('id')
|
|
130
130
|
def activate_user(id, options = {})
|
|
131
|
-
post("/users/#{id}/lifecycle/activate", options)
|
|
131
|
+
post("/users/#{path_segment(id)}/lifecycle/activate", options)
|
|
132
132
|
end
|
|
133
133
|
|
|
134
134
|
# Reactivate User
|
|
@@ -146,7 +146,7 @@ module Oktakit
|
|
|
146
146
|
# Oktakit.reactivate_user('id')
|
|
147
147
|
|
|
148
148
|
def reactivate_user(id, options = {})
|
|
149
|
-
post("/users/#{id}/lifecycle/reactivate", options)
|
|
149
|
+
post("/users/#{path_segment(id)}/lifecycle/reactivate", options)
|
|
150
150
|
end
|
|
151
151
|
|
|
152
152
|
# Deactivate User
|
|
@@ -162,7 +162,7 @@ module Oktakit
|
|
|
162
162
|
# @example
|
|
163
163
|
# Oktakit.deactivate_user('id')
|
|
164
164
|
def deactivate_user(id, options = {})
|
|
165
|
-
post("/users/#{id}/lifecycle/deactivate", options)
|
|
165
|
+
post("/users/#{path_segment(id)}/lifecycle/deactivate", options)
|
|
166
166
|
end
|
|
167
167
|
|
|
168
168
|
# Delete User
|
|
@@ -180,7 +180,7 @@ module Oktakit
|
|
|
180
180
|
# @example
|
|
181
181
|
# Oktakit.delete_user('id')
|
|
182
182
|
def delete_user(id, options = {})
|
|
183
|
-
delete("/users/#{id}", options)
|
|
183
|
+
delete("/users/#{path_segment(id)}", options)
|
|
184
184
|
end
|
|
185
185
|
|
|
186
186
|
# Suspend User
|
|
@@ -196,7 +196,7 @@ module Oktakit
|
|
|
196
196
|
# @example
|
|
197
197
|
# Oktakit.suspend_user('id')
|
|
198
198
|
def suspend_user(id, options = {})
|
|
199
|
-
post("/users/#{id}/lifecycle/suspend", options)
|
|
199
|
+
post("/users/#{path_segment(id)}/lifecycle/suspend", options)
|
|
200
200
|
end
|
|
201
201
|
|
|
202
202
|
# Unsuspend User
|
|
@@ -212,7 +212,7 @@ module Oktakit
|
|
|
212
212
|
# @example
|
|
213
213
|
# Oktakit.unsuspend_user('id')
|
|
214
214
|
def unsuspend_user(id, options = {})
|
|
215
|
-
post("/users/#{id}/lifecycle/unsuspend", options)
|
|
215
|
+
post("/users/#{path_segment(id)}/lifecycle/unsuspend", options)
|
|
216
216
|
end
|
|
217
217
|
|
|
218
218
|
# Unlock User
|
|
@@ -228,7 +228,7 @@ module Oktakit
|
|
|
228
228
|
# @example
|
|
229
229
|
# Oktakit.unlock_user('id')
|
|
230
230
|
def unlock_user(id, options = {})
|
|
231
|
-
post("/users/#{id}/lifecycle/unlock", options)
|
|
231
|
+
post("/users/#{path_segment(id)}/lifecycle/unlock", options)
|
|
232
232
|
end
|
|
233
233
|
|
|
234
234
|
# Reset Password
|
|
@@ -244,7 +244,7 @@ module Oktakit
|
|
|
244
244
|
# @example
|
|
245
245
|
# Oktakit.reset_password('id')
|
|
246
246
|
def reset_password(id, options = {})
|
|
247
|
-
post("/users/#{id}/lifecycle/reset_password", options)
|
|
247
|
+
post("/users/#{path_segment(id)}/lifecycle/reset_password", options)
|
|
248
248
|
end
|
|
249
249
|
|
|
250
250
|
# Expire Password
|
|
@@ -260,7 +260,7 @@ module Oktakit
|
|
|
260
260
|
# @example
|
|
261
261
|
# Oktakit.expire_password('id')
|
|
262
262
|
def expire_password(id, options = {})
|
|
263
|
-
post("/users/#{id}/lifecycle/expire_password", options)
|
|
263
|
+
post("/users/#{path_segment(id)}/lifecycle/expire_password", options)
|
|
264
264
|
end
|
|
265
265
|
|
|
266
266
|
# Reset Factors
|
|
@@ -276,7 +276,7 @@ module Oktakit
|
|
|
276
276
|
# @example
|
|
277
277
|
# Oktakit.reset_factors('id')
|
|
278
278
|
def reset_factors(id, options = {})
|
|
279
|
-
post("/users/#{id}/lifecycle/reset_factors", options)
|
|
279
|
+
post("/users/#{path_segment(id)}/lifecycle/reset_factors", options)
|
|
280
280
|
end
|
|
281
281
|
|
|
282
282
|
# Forgot Password
|
|
@@ -292,7 +292,7 @@ module Oktakit
|
|
|
292
292
|
# @example
|
|
293
293
|
# Oktakit.forgot_password('id')
|
|
294
294
|
def forgot_password(id, options = {})
|
|
295
|
-
post("/users/#{id}/credentials/forgot_password", options)
|
|
295
|
+
post("/users/#{path_segment(id)}/credentials/forgot_password", options)
|
|
296
296
|
end
|
|
297
297
|
|
|
298
298
|
# Change Password
|
|
@@ -308,7 +308,7 @@ module Oktakit
|
|
|
308
308
|
# @example
|
|
309
309
|
# Oktakit.change_password('id')
|
|
310
310
|
def change_password(id, options = {})
|
|
311
|
-
post("/users/#{id}/credentials/change_password", options)
|
|
311
|
+
post("/users/#{path_segment(id)}/credentials/change_password", options)
|
|
312
312
|
end
|
|
313
313
|
|
|
314
314
|
# Change Recovery Question
|
|
@@ -324,7 +324,7 @@ module Oktakit
|
|
|
324
324
|
# @example
|
|
325
325
|
# Oktakit.change_recovery_question('id')
|
|
326
326
|
def change_recovery_question(id, options = {})
|
|
327
|
-
post("/users/#{id}/credentials/change_recovery_question", options)
|
|
327
|
+
post("/users/#{path_segment(id)}/credentials/change_recovery_question", options)
|
|
328
328
|
end
|
|
329
329
|
|
|
330
330
|
# Clear user sessions
|
|
@@ -339,7 +339,7 @@ module Oktakit
|
|
|
339
339
|
# @see https://developer.okta.com/docs/api/resources/users#user-sessions
|
|
340
340
|
# Oktakit.clear_user_sessions('id')
|
|
341
341
|
def clear_user_sessions(id, options = {})
|
|
342
|
-
delete("/users/#{id}/sessions", options)
|
|
342
|
+
delete("/users/#{path_segment(id)}/sessions", options)
|
|
343
343
|
end
|
|
344
344
|
end
|
|
345
345
|
end
|
data/lib/oktakit/client.rb
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
require "json"
|
|
1
2
|
require 'sawyer'
|
|
2
3
|
require 'oktakit/response/raise_error'
|
|
3
4
|
require 'oktakit/client/admin_roles'
|
|
@@ -24,13 +25,22 @@ module Oktakit
|
|
|
24
25
|
include Templates
|
|
25
26
|
include Users
|
|
26
27
|
|
|
27
|
-
#
|
|
28
|
-
|
|
28
|
+
# Bytes that path_segment percent-encodes: everything except RFC 3986 unreserved characters.
|
|
29
|
+
PATH_SEGMENT_UNSAFE = /[^A-Za-z0-9\-._~]/n
|
|
30
|
+
|
|
31
|
+
# Bytes that request percent-encodes in a full path: everything outside the RFC 2396
|
|
32
|
+
# unreserved and reserved sets, plus any "%" that does not start a valid escape sequence.
|
|
33
|
+
# Existing escapes are preserved so already-encoded segments are not encoded twice.
|
|
34
|
+
REQUEST_PATH_UNSAFE = %r{[^\-_.!~*'()a-zA-Z\d;/?:@&=+$,\[\]%]|%(?![0-9A-Fa-f]{2})}n
|
|
35
|
+
# A single DNS label: letters, digits and inner hyphens, at most 63 characters.
|
|
36
|
+
ORGANIZATION_FORMAT = /\A[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\z/i
|
|
37
|
+
|
|
38
|
+
private_constant :PATH_SEGMENT_UNSAFE, :REQUEST_PATH_UNSAFE, :ORGANIZATION_FORMAT
|
|
29
39
|
|
|
30
40
|
# Default Faraday middleware stack
|
|
31
|
-
MIDDLEWARE =
|
|
41
|
+
MIDDLEWARE = Faraday::RackBuilder.new do |builder|
|
|
32
42
|
builder.use(Oktakit::Response::RaiseError)
|
|
33
|
-
builder.adapter(
|
|
43
|
+
builder.adapter(:net_http)
|
|
34
44
|
end
|
|
35
45
|
|
|
36
46
|
def initialize(token: nil, access_token: nil, organization: nil, api_endpoint: nil)
|
|
@@ -42,6 +52,12 @@ module Oktakit
|
|
|
42
52
|
raise ArgumentError, "Please provide either the token or the access_token argument"
|
|
43
53
|
end
|
|
44
54
|
|
|
55
|
+
# The organization becomes the hostname the token is sent to, so it must be a single DNS label.
|
|
56
|
+
if !api_endpoint && !ORGANIZATION_FORMAT.match?(organization.to_s)
|
|
57
|
+
raise ArgumentError, "Invalid organization: #{organization.inspect}. Use the Okta subdomain, " \
|
|
58
|
+
"e.g. \"my-org\" for my-org.okta.com, or pass api_endpoint instead."
|
|
59
|
+
end
|
|
60
|
+
|
|
45
61
|
@token = token
|
|
46
62
|
@access_token = access_token
|
|
47
63
|
@organization = organization
|
|
@@ -176,7 +192,7 @@ module Oktakit
|
|
|
176
192
|
options[:headers][:accept] = accept if accept
|
|
177
193
|
options[:headers][:content_type] = content_type if content_type
|
|
178
194
|
|
|
179
|
-
uri =
|
|
195
|
+
uri = escape_request_path("/api/v1" + path.to_s)
|
|
180
196
|
@last_response = resp = sawyer_agent.call(method, uri, data, options)
|
|
181
197
|
|
|
182
198
|
response = [resp.data, resp.status]
|
|
@@ -184,6 +200,37 @@ module Oktakit
|
|
|
184
200
|
response
|
|
185
201
|
end
|
|
186
202
|
|
|
203
|
+
# Percent-encode a single value for use as one URL path segment.
|
|
204
|
+
#
|
|
205
|
+
# Everything outside the RFC 3986 unreserved set is percent-encoded, including "?", "#"
|
|
206
|
+
# and "%". Some values cannot be made safe by encoding and are rejected instead:
|
|
207
|
+
#
|
|
208
|
+
# - empty values, "." and "..", which resolve to a different resource;
|
|
209
|
+
# - values containing "/", because Okta decodes "%2F" back into a path separator;
|
|
210
|
+
# - values containing ";", because Okta ignores everything from ";" (or "%3B") onward.
|
|
211
|
+
#
|
|
212
|
+
# Okta only supports fetching logins that contain "/" by user ID.
|
|
213
|
+
#
|
|
214
|
+
# @param value [#to_s] Resource identifier, e.g. an Okta ID or a user login
|
|
215
|
+
# @return [String] The encoded segment
|
|
216
|
+
# @raise [ArgumentError] If the value is empty, ".", "..", or contains "/" or ";"
|
|
217
|
+
def path_segment(value)
|
|
218
|
+
segment = value.to_s
|
|
219
|
+
if segment.empty? || segment == "." || segment == ".." || segment.include?("/") || segment.include?(";")
|
|
220
|
+
raise ArgumentError, "Invalid path segment: #{value.inspect}"
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
percent_encode(segment, PATH_SEGMENT_UNSAFE)
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
def escape_request_path(path)
|
|
227
|
+
percent_encode(path, REQUEST_PATH_UNSAFE)
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
def percent_encode(string, unsafe)
|
|
231
|
+
string.b.gsub(unsafe) { |byte| format("%%%02X", byte.ord) }.force_encoding(Encoding::US_ASCII)
|
|
232
|
+
end
|
|
233
|
+
|
|
187
234
|
def sawyer_agent
|
|
188
235
|
@sawyer_agent ||= Sawyer::Agent.new(api_endpoint, sawyer_options) do |http|
|
|
189
236
|
http.headers[:accept] = 'application/json'
|
|
@@ -6,7 +6,7 @@ module Oktakit
|
|
|
6
6
|
module Response
|
|
7
7
|
# This class raises an Oktakit-flavored exception based
|
|
8
8
|
# HTTP status codes returned by the API
|
|
9
|
-
class RaiseError < Faraday::
|
|
9
|
+
class RaiseError < Faraday::Middleware
|
|
10
10
|
private
|
|
11
11
|
|
|
12
12
|
def on_complete(response)
|