stytch 6.6.0 → 7.0.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/README.md +1 -1
- data/lib/stytch/b2b_client.rb +9 -3
- data/lib/stytch/b2b_discovery.rb +24 -11
- data/lib/stytch/b2b_magic_links.rb +23 -7
- data/lib/stytch/b2b_oauth.rb +12 -2
- data/lib/stytch/b2b_organizations.rb +261 -41
- data/lib/stytch/b2b_otp.rb +4 -2
- data/lib/stytch/b2b_passwords.rb +35 -9
- data/lib/stytch/b2b_rbac.rb +48 -0
- data/lib/stytch/b2b_sessions.rb +106 -38
- data/lib/stytch/b2b_sso.rb +127 -21
- data/lib/stytch/client.rb +2 -2
- data/lib/stytch/crypto_wallets.rb +4 -2
- data/lib/stytch/errors.rb +14 -0
- data/lib/stytch/m2m.rb +16 -9
- data/lib/stytch/magic_links.rb +12 -6
- data/lib/stytch/method_options.rb +22 -0
- data/lib/stytch/oauth.rb +4 -2
- data/lib/stytch/otps.rb +14 -7
- data/lib/stytch/passwords.rb +16 -8
- data/lib/stytch/rbac_local.rb +58 -0
- data/lib/stytch/request_helper.rb +12 -8
- data/lib/stytch/sessions.rb +24 -11
- data/lib/stytch/totps.rb +8 -4
- data/lib/stytch/users.rb +29 -15
- data/lib/stytch/version.rb +1 -1
- data/lib/stytch/webauthn.rb +39 -24
- metadata +5 -2
@@ -9,6 +9,44 @@
|
|
9
9
|
require_relative 'request_helper'
|
10
10
|
|
11
11
|
module StytchB2B
|
12
|
+
class UpdateRequestOptions
|
13
|
+
# Optional authorization object.
|
14
|
+
# Pass in an active Stytch Member session token or session JWT and the request
|
15
|
+
# will be run using that member's permissions.
|
16
|
+
attr_accessor :authorization
|
17
|
+
|
18
|
+
def initialize(
|
19
|
+
authorization: nil
|
20
|
+
)
|
21
|
+
@authorization = authorization
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_headers
|
25
|
+
headers = {}
|
26
|
+
headers.merge!(@authorization.to_headers) if authorization
|
27
|
+
headers
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class DeleteRequestOptions
|
32
|
+
# Optional authorization object.
|
33
|
+
# Pass in an active Stytch Member session token or session JWT and the request
|
34
|
+
# will be run using that member's permissions.
|
35
|
+
attr_accessor :authorization
|
36
|
+
|
37
|
+
def initialize(
|
38
|
+
authorization: nil
|
39
|
+
)
|
40
|
+
@authorization = authorization
|
41
|
+
end
|
42
|
+
|
43
|
+
def to_headers
|
44
|
+
headers = {}
|
45
|
+
headers.merge!(@authorization.to_headers) if authorization
|
46
|
+
headers
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
12
50
|
class Organizations
|
13
51
|
include Stytch::RequestHelper
|
14
52
|
attr_reader :members
|
@@ -55,11 +93,11 @@ module StytchB2B
|
|
55
93
|
# Common domains such as `gmail.com` are not allowed. See the [common email domains resource](https://stytch.com/docs/b2b/api/common-email-domains) for the full list.
|
56
94
|
# The type of this field is nilable list of +String+.
|
57
95
|
# email_jit_provisioning::
|
58
|
-
# The authentication setting that controls how a new Member can be provisioned by authenticating via Email Magic Link. The accepted values are:
|
96
|
+
# The authentication setting that controls how a new Member can be provisioned by authenticating via Email Magic Link or OAuth. The accepted values are:
|
59
97
|
#
|
60
|
-
# `RESTRICTED` – only new Members with verified emails that comply with `email_allowed_domains` can be provisioned upon authentication via Email Magic Link.
|
98
|
+
# `RESTRICTED` – only new Members with verified emails that comply with `email_allowed_domains` can be provisioned upon authentication via Email Magic Link or OAuth.
|
61
99
|
#
|
62
|
-
# `NOT_ALLOWED` – disable JIT provisioning via Email Magic Link.
|
100
|
+
# `NOT_ALLOWED` – disable JIT provisioning via Email Magic Link and OAuth.
|
63
101
|
#
|
64
102
|
# The type of this field is nilable +String+.
|
65
103
|
# email_invites::
|
@@ -81,7 +119,6 @@ module StytchB2B
|
|
81
119
|
#
|
82
120
|
# The type of this field is nilable +String+.
|
83
121
|
# allowed_auth_methods::
|
84
|
-
#
|
85
122
|
# An array of allowed authentication methods. This list is enforced when `auth_methods` is set to `RESTRICTED`.
|
86
123
|
# The list's accepted values are: `sso`, `magic_link`, `password`, `google_oauth`, and `microsoft_oauth`.
|
87
124
|
#
|
@@ -89,11 +126,17 @@ module StytchB2B
|
|
89
126
|
# mfa_policy::
|
90
127
|
# The setting that controls the MFA policy for all Members in the Organization. The accepted values are:
|
91
128
|
#
|
92
|
-
# `REQUIRED_FOR_ALL` – All Members within the Organization will be required to complete MFA every time they wish to log in.
|
129
|
+
# `REQUIRED_FOR_ALL` – All Members within the Organization will be required to complete MFA every time they wish to log in. However, any active Session that existed prior to this setting change will remain valid.
|
93
130
|
#
|
94
131
|
# `OPTIONAL` – The default value. The Organization does not require MFA by default for all Members. Members will be required to complete MFA only if their `mfa_enrolled` status is set to true.
|
95
132
|
#
|
96
133
|
# The type of this field is nilable +String+.
|
134
|
+
# rbac_email_implicit_role_assignments::
|
135
|
+
# (Coming Soon) Implicit role assignments based off of email domains.
|
136
|
+
# For each domain-Role pair, all Members whose email addresses have the specified email domain will be granted the
|
137
|
+
# associated Role, regardless of their login method. See the [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/role-assignment)
|
138
|
+
# for more information about role assignment.
|
139
|
+
# The type of this field is nilable list of +EmailImplicitRoleAssignment+ (+object+).
|
97
140
|
#
|
98
141
|
# == Returns:
|
99
142
|
# An object with the following fields:
|
@@ -117,8 +160,10 @@ module StytchB2B
|
|
117
160
|
email_invites: nil,
|
118
161
|
auth_methods: nil,
|
119
162
|
allowed_auth_methods: nil,
|
120
|
-
mfa_policy: nil
|
163
|
+
mfa_policy: nil,
|
164
|
+
rbac_email_implicit_role_assignments: nil
|
121
165
|
)
|
166
|
+
headers = {}
|
122
167
|
request = {
|
123
168
|
organization_name: organization_name
|
124
169
|
}
|
@@ -132,8 +177,9 @@ module StytchB2B
|
|
132
177
|
request[:auth_methods] = auth_methods unless auth_methods.nil?
|
133
178
|
request[:allowed_auth_methods] = allowed_auth_methods unless allowed_auth_methods.nil?
|
134
179
|
request[:mfa_policy] = mfa_policy unless mfa_policy.nil?
|
180
|
+
request[:rbac_email_implicit_role_assignments] = rbac_email_implicit_role_assignments unless rbac_email_implicit_role_assignments.nil?
|
135
181
|
|
136
|
-
post_request('/v1/b2b/organizations', request)
|
182
|
+
post_request('/v1/b2b/organizations', request, headers)
|
137
183
|
end
|
138
184
|
|
139
185
|
# Returns an Organization specified by `organization_id`.
|
@@ -157,33 +203,56 @@ module StytchB2B
|
|
157
203
|
def get(
|
158
204
|
organization_id:
|
159
205
|
)
|
206
|
+
headers = {}
|
160
207
|
query_params = {}
|
161
208
|
request = request_with_query_params("/v1/b2b/organizations/#{organization_id}", query_params)
|
162
|
-
get_request(request)
|
209
|
+
get_request(request, headers)
|
163
210
|
end
|
164
211
|
|
165
212
|
# Updates an Organization specified by `organization_id`. An Organization must always have at least one auth setting set to either `RESTRICTED` or `ALL_ALLOWED` in order to provision new Members.
|
166
213
|
#
|
167
214
|
# *See the [Organization authentication settings](https://stytch.com/docs/b2b/api/org-auth-settings) resource to learn more about fields like `email_jit_provisioning`, `email_invites`, `sso_jit_provisioning`, etc., and their behaviors.
|
168
215
|
#
|
216
|
+
# (Coming Soon) Our RBAC implementation offers out-of-the-box handling of authorization checks for this endpoint. If you pass in
|
217
|
+
# a header containing a `session_token` or a `session_jwt` for an unexpired Member Session, we will check that the
|
218
|
+
# Member Session has the necessary permissions. The specific permissions needed depend on which of the optional fields
|
219
|
+
# are passed in the request. For example, if the `organization_name` argument is provided, the Member Session must have
|
220
|
+
# permission to perform the `update.info.name` action on the `stytch.organization` Resource.
|
221
|
+
#
|
222
|
+
# If the Member Session does not contain a Role that satisfies the requested permissions, or if the Member's Organization
|
223
|
+
# does not match the `organization_id` passed in the request, a 403 error will be thrown. Otherwise, the request will
|
224
|
+
# proceed as normal.
|
225
|
+
#
|
226
|
+
# To learn more about our RBAC implementation, see our [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/overview).
|
227
|
+
#
|
169
228
|
# == Parameters:
|
170
229
|
# organization_id::
|
171
230
|
# Globally unique UUID that identifies a specific Organization. The `organization_id` is critical to perform operations on an Organization, so be sure to preserve this value.
|
172
231
|
# The type of this field is +String+.
|
173
232
|
# organization_name::
|
174
233
|
# The name of the Organization. Must be between 1 and 128 characters in length.
|
234
|
+
#
|
235
|
+
# If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.info.name` action on the `stytch.organization` Resource.
|
175
236
|
# The type of this field is nilable +String+.
|
176
237
|
# organization_slug::
|
177
238
|
# The unique URL slug of the Organization. The slug only accepts alphanumeric characters and the following reserved characters: `-` `.` `_` `~`. Must be between 2 and 128 characters in length.
|
239
|
+
#
|
240
|
+
# If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.info.slug` action on the `stytch.organization` Resource.
|
178
241
|
# The type of this field is nilable +String+.
|
179
242
|
# organization_logo_url::
|
180
243
|
# The image URL of the Organization logo.
|
244
|
+
#
|
245
|
+
# If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.info.logo-url` action on the `stytch.organization` Resource.
|
181
246
|
# The type of this field is nilable +String+.
|
182
247
|
# trusted_metadata::
|
183
248
|
# An arbitrary JSON object for storing application-specific data or identity-provider-specific data.
|
249
|
+
# If a session header is passed into the request, this field may **not** be passed into the request. You cannot
|
250
|
+
# update trusted metadata when acting as a Member.
|
184
251
|
# The type of this field is nilable +object+.
|
185
252
|
# sso_default_connection_id::
|
186
253
|
# The default connection used for SSO when there are multiple active connections.
|
254
|
+
#
|
255
|
+
# If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.settings.default-sso-connection` action on the `stytch.organization` Resource.
|
187
256
|
# The type of this field is nilable +String+.
|
188
257
|
# sso_jit_provisioning::
|
189
258
|
# The authentication setting that controls the JIT provisioning of Members when authenticating via SSO. The accepted values are:
|
@@ -194,24 +263,32 @@ module StytchB2B
|
|
194
263
|
#
|
195
264
|
# `NOT_ALLOWED` – disable JIT provisioning via SSO.
|
196
265
|
#
|
266
|
+
#
|
267
|
+
# If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.settings.sso-jit-provisioning` action on the `stytch.organization` Resource.
|
197
268
|
# The type of this field is nilable +String+.
|
198
269
|
# sso_jit_provisioning_allowed_connections::
|
199
270
|
# An array of `connection_id`s that reference [SAML Connection objects](https://stytch.com/docs/b2b/api/saml-connection-object).
|
200
271
|
# Only these connections will be allowed to JIT provision Members via SSO when `sso_jit_provisioning` is set to `RESTRICTED`.
|
272
|
+
#
|
273
|
+
# If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.settings.sso-jit-provisioning` action on the `stytch.organization` Resource.
|
201
274
|
# The type of this field is nilable list of +String+.
|
202
275
|
# email_allowed_domains::
|
203
276
|
# An array of email domains that allow invites or JIT provisioning for new Members. This list is enforced when either `email_invites` or `email_jit_provisioning` is set to `RESTRICTED`.
|
204
277
|
#
|
205
278
|
#
|
206
279
|
# Common domains such as `gmail.com` are not allowed. See the [common email domains resource](https://stytch.com/docs/b2b/api/common-email-domains) for the full list.
|
280
|
+
#
|
281
|
+
# If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.settings.allowed-domains` action on the `stytch.organization` Resource.
|
207
282
|
# The type of this field is nilable list of +String+.
|
208
283
|
# email_jit_provisioning::
|
209
|
-
# The authentication setting that controls how a new Member can be provisioned by authenticating via Email Magic Link. The accepted values are:
|
284
|
+
# The authentication setting that controls how a new Member can be provisioned by authenticating via Email Magic Link or OAuth. The accepted values are:
|
210
285
|
#
|
211
|
-
# `RESTRICTED` – only new Members with verified emails that comply with `email_allowed_domains` can be provisioned upon authentication via Email Magic Link.
|
286
|
+
# `RESTRICTED` – only new Members with verified emails that comply with `email_allowed_domains` can be provisioned upon authentication via Email Magic Link or OAuth.
|
212
287
|
#
|
213
|
-
# `NOT_ALLOWED` – disable JIT provisioning via Email Magic Link.
|
288
|
+
# `NOT_ALLOWED` – disable JIT provisioning via Email Magic Link and OAuth.
|
214
289
|
#
|
290
|
+
#
|
291
|
+
# If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.settings.email-jit-provisioning` action on the `stytch.organization` Resource.
|
215
292
|
# The type of this field is nilable +String+.
|
216
293
|
# email_invites::
|
217
294
|
# The authentication setting that controls how a new Member can be invited to an organization by email. The accepted values are:
|
@@ -222,6 +299,8 @@ module StytchB2B
|
|
222
299
|
#
|
223
300
|
# `NOT_ALLOWED` – disable email invites.
|
224
301
|
#
|
302
|
+
#
|
303
|
+
# If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.settings.email-invites` action on the `stytch.organization` Resource.
|
225
304
|
# The type of this field is nilable +String+.
|
226
305
|
# auth_methods::
|
227
306
|
# The setting that controls which authentication methods can be used by Members of an Organization. The accepted values are:
|
@@ -230,21 +309,34 @@ module StytchB2B
|
|
230
309
|
#
|
231
310
|
# `RESTRICTED` – only methods that comply with `allowed_auth_methods` can be used for authentication. This setting does not apply to Members with `is_breakglass` set to `true`.
|
232
311
|
#
|
312
|
+
#
|
313
|
+
# If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.settings.allowed-auth-methods` action on the `stytch.organization` Resource.
|
233
314
|
# The type of this field is nilable +String+.
|
234
315
|
# allowed_auth_methods::
|
235
|
-
#
|
236
316
|
# An array of allowed authentication methods. This list is enforced when `auth_methods` is set to `RESTRICTED`.
|
237
317
|
# The list's accepted values are: `sso`, `magic_link`, `password`, `google_oauth`, and `microsoft_oauth`.
|
238
318
|
#
|
319
|
+
#
|
320
|
+
# If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.settings.allowed-auth-methods` action on the `stytch.organization` Resource.
|
239
321
|
# The type of this field is nilable list of +String+.
|
240
322
|
# mfa_policy::
|
241
323
|
# The setting that controls the MFA policy for all Members in the Organization. The accepted values are:
|
242
324
|
#
|
243
|
-
# `REQUIRED_FOR_ALL` – All Members within the Organization will be required to complete MFA every time they wish to log in.
|
325
|
+
# `REQUIRED_FOR_ALL` – All Members within the Organization will be required to complete MFA every time they wish to log in. However, any active Session that existed prior to this setting change will remain valid.
|
244
326
|
#
|
245
327
|
# `OPTIONAL` – The default value. The Organization does not require MFA by default for all Members. Members will be required to complete MFA only if their `mfa_enrolled` status is set to true.
|
246
328
|
#
|
329
|
+
#
|
330
|
+
# If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.settings.mfa-policy` action on the `stytch.organization` Resource.
|
247
331
|
# The type of this field is nilable +String+.
|
332
|
+
# rbac_email_implicit_role_assignments::
|
333
|
+
# (Coming Soon) Implicit role assignments based off of email domains.
|
334
|
+
# For each domain-Role pair, all Members whose email addresses have the specified email domain will be granted the
|
335
|
+
# associated Role, regardless of their login method. See the [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/role-assignment)
|
336
|
+
# for more information about role assignment.
|
337
|
+
#
|
338
|
+
# If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.settings.implicit-roles` action on the `stytch.organization` Resource.
|
339
|
+
# The type of this field is nilable list of +String+.
|
248
340
|
#
|
249
341
|
# == Returns:
|
250
342
|
# An object with the following fields:
|
@@ -257,6 +349,9 @@ module StytchB2B
|
|
257
349
|
# status_code::
|
258
350
|
# The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
|
259
351
|
# The type of this field is +Integer+.
|
352
|
+
#
|
353
|
+
# == Method Options:
|
354
|
+
# This method supports an optional +UpdateRequestOptions+ object which will modify the headers sent in the HTTP request.
|
260
355
|
def update(
|
261
356
|
organization_id:,
|
262
357
|
organization_name: nil,
|
@@ -271,8 +366,12 @@ module StytchB2B
|
|
271
366
|
email_invites: nil,
|
272
367
|
auth_methods: nil,
|
273
368
|
allowed_auth_methods: nil,
|
274
|
-
mfa_policy: nil
|
369
|
+
mfa_policy: nil,
|
370
|
+
rbac_email_implicit_role_assignments: nil,
|
371
|
+
method_options: nil
|
275
372
|
)
|
373
|
+
headers = {}
|
374
|
+
headers = headers.merge(method_options.to_headers) unless method_options.nil?
|
276
375
|
request = {}
|
277
376
|
request[:organization_name] = organization_name unless organization_name.nil?
|
278
377
|
request[:organization_slug] = organization_slug unless organization_slug.nil?
|
@@ -287,11 +386,12 @@ module StytchB2B
|
|
287
386
|
request[:auth_methods] = auth_methods unless auth_methods.nil?
|
288
387
|
request[:allowed_auth_methods] = allowed_auth_methods unless allowed_auth_methods.nil?
|
289
388
|
request[:mfa_policy] = mfa_policy unless mfa_policy.nil?
|
389
|
+
request[:rbac_email_implicit_role_assignments] = rbac_email_implicit_role_assignments unless rbac_email_implicit_role_assignments.nil?
|
290
390
|
|
291
|
-
put_request("/v1/b2b/organizations/#{organization_id}", request)
|
391
|
+
put_request("/v1/b2b/organizations/#{organization_id}", request, headers)
|
292
392
|
end
|
293
393
|
|
294
|
-
# Deletes an Organization specified by `organization_id`. All Members of the Organization will also be deleted.
|
394
|
+
# Deletes an Organization specified by `organization_id`. All Members of the Organization will also be deleted. /%}
|
295
395
|
#
|
296
396
|
# == Parameters:
|
297
397
|
# organization_id::
|
@@ -309,10 +409,16 @@ module StytchB2B
|
|
309
409
|
# status_code::
|
310
410
|
# The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
|
311
411
|
# The type of this field is +Integer+.
|
412
|
+
#
|
413
|
+
# == Method Options:
|
414
|
+
# This method supports an optional +DeleteRequestOptions+ object which will modify the headers sent in the HTTP request.
|
312
415
|
def delete(
|
313
|
-
organization_id
|
416
|
+
organization_id:,
|
417
|
+
method_options: nil
|
314
418
|
)
|
315
|
-
|
419
|
+
headers = {}
|
420
|
+
headers = headers.merge(method_options.to_headers) unless method_options.nil?
|
421
|
+
delete_request("/v1/b2b/organizations/#{organization_id}", headers)
|
316
422
|
end
|
317
423
|
|
318
424
|
# Search for Organizations. If you send a request with no body params, no filtering will be applied and the endpoint will return all Organizations. All fuzzy search filters require a minimum of three characters.
|
@@ -347,12 +453,13 @@ module StytchB2B
|
|
347
453
|
limit: nil,
|
348
454
|
query: nil
|
349
455
|
)
|
456
|
+
headers = {}
|
350
457
|
request = {}
|
351
458
|
request[:cursor] = cursor unless cursor.nil?
|
352
459
|
request[:limit] = limit unless limit.nil?
|
353
460
|
request[:query] = query unless query.nil?
|
354
461
|
|
355
|
-
post_request('/v1/b2b/organizations/search', request)
|
462
|
+
post_request('/v1/b2b/organizations/search', request, headers)
|
356
463
|
end
|
357
464
|
|
358
465
|
class Members
|
@@ -364,6 +471,18 @@ module StytchB2B
|
|
364
471
|
|
365
472
|
# Updates a Member specified by `organization_id` and `member_id`.
|
366
473
|
#
|
474
|
+
# (Coming Soon) Our RBAC implementation offers out-of-the-box handling of authorization checks for this endpoint. If you pass in
|
475
|
+
# a header containing a `session_token` or a `session_jwt` for an unexpired Member Session, we will check that the
|
476
|
+
# Member Session has the necessary permissions. The specific permissions needed depend on which of the optional fields
|
477
|
+
# are passed in the request. For example, if the `organization_name` argument is provided, the Member Session must have
|
478
|
+
# permission to perform the `update.info.name` action on the `stytch.organization` Resource.
|
479
|
+
#
|
480
|
+
# If the Member Session does not contain a Role that satisfies the requested permissions, or if the Member's Organization
|
481
|
+
# does not match the `organization_id` passed in the request, a 403 error will be thrown. Otherwise, the request will
|
482
|
+
# proceed as normal.
|
483
|
+
#
|
484
|
+
# To learn more about our RBAC implementation, see our [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/overview).
|
485
|
+
#
|
367
486
|
# == Parameters:
|
368
487
|
# organization_id::
|
369
488
|
# Globally unique UUID that identifies a specific Organization. The `organization_id` is critical to perform operations on an Organization, so be sure to preserve this value.
|
@@ -371,26 +490,59 @@ module StytchB2B
|
|
371
490
|
# member_id::
|
372
491
|
# Globally unique UUID that identifies a specific Member. The `member_id` is critical to perform operations on a Member, so be sure to preserve this value.
|
373
492
|
# The type of this field is +String+.
|
493
|
+
# preserve_existing_sessions::
|
494
|
+
# (Coming Soon) Whether to preserve existing sessions when explicit Roles that are revoked are also implicitly assigned
|
495
|
+
# by SSO connection or SSO group. Defaults to `false` - that is, existing Member Sessions that contain SSO
|
496
|
+
# authentication factors with the affected SSO connection IDs will be revoked.
|
497
|
+
# The type of this field is +Boolean+.
|
374
498
|
# name::
|
375
499
|
# The name of the Member.
|
500
|
+
#
|
501
|
+
# If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.info.name` action on the `stytch.member` Resource.
|
502
|
+
# Alternatively, if the Member Session matches the Member associated with the `member_id` passed in the request, the authorization check will also allow a Member Session that has permission to perform the `update.info.name` action on the `stytch.self` Resource.
|
376
503
|
# The type of this field is nilable +String+.
|
377
504
|
# trusted_metadata::
|
378
505
|
# An arbitrary JSON object for storing application-specific data or identity-provider-specific data.
|
506
|
+
# If a session header is passed into the request, this field may **not** be passed into the request. You cannot
|
507
|
+
# update trusted metadata when acting as a Member.
|
379
508
|
# The type of this field is nilable +object+.
|
380
509
|
# untrusted_metadata::
|
381
510
|
# An arbitrary JSON object of application-specific data. These fields can be edited directly by the
|
382
511
|
# frontend SDK, and should not be used to store critical information. See the [Metadata resource](https://stytch.com/docs/b2b/api/metadata)
|
383
512
|
# for complete field behavior details.
|
513
|
+
#
|
514
|
+
# If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.info.untrusted-metadata` action on the `stytch.member` Resource.
|
515
|
+
# Alternatively, if the Member Session matches the Member associated with the `member_id` passed in the request, the authorization check will also allow a Member Session that has permission to perform the `update.info.untrusted-metadata` action on the `stytch.self` Resource.
|
384
516
|
# The type of this field is nilable +object+.
|
385
517
|
# is_breakglass::
|
386
518
|
# Identifies the Member as a break glass user - someone who has permissions to authenticate into an Organization by bypassing the Organization's settings. A break glass account is typically used for emergency purposes to gain access outside of normal authentication procedures. Refer to the [Organization object](organization-object) and its `auth_methods` and `allowed_auth_methods` fields for more details.
|
519
|
+
#
|
520
|
+
# If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.info.is-breakglass` action on the `stytch.member` Resource.
|
387
521
|
# The type of this field is nilable +Boolean+.
|
388
522
|
# mfa_phone_number::
|
389
523
|
# Sets the Member's phone number. Throws an error if the Member already has a phone number. To change the Member's phone number, use the [Delete member phone number endpoint](https://stytch.com/docs/b2b/api/delete-member-mfa-phone-number) to delete the Member's existing phone number first.
|
524
|
+
#
|
525
|
+
# If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.info.mfa-phone` action on the `stytch.member` Resource.
|
526
|
+
# Alternatively, if the Member Session matches the Member associated with the `member_id` passed in the request, the authorization check will also allow a Member Session that has permission to perform the `update.info.mfa-phone` action on the `stytch.self` Resource.
|
390
527
|
# The type of this field is nilable +String+.
|
391
528
|
# mfa_enrolled::
|
392
529
|
# Sets whether the Member is enrolled in MFA. If true, the Member must complete an MFA step whenever they wish to log in to their Organization. If false, the Member only needs to complete an MFA step if the Organization's MFA policy is set to `REQUIRED_FOR_ALL`.
|
530
|
+
#
|
531
|
+
# If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.settings.mfa-enrolled` action on the `stytch.member` Resource.
|
532
|
+
# Alternatively, if the Member Session matches the Member associated with the `member_id` passed in the request, the authorization check will also allow a Member Session that has permission to perform the `update.settings.mfa-enrolled` action on the `stytch.self` Resource.
|
393
533
|
# The type of this field is nilable +Boolean+.
|
534
|
+
# roles::
|
535
|
+
# (Coming Soon) Roles to explicitly assign to this Member.
|
536
|
+
# Will completely replace any existing explicitly assigned roles. See the
|
537
|
+
# [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/role-assignment) for more information about role assignment.
|
538
|
+
#
|
539
|
+
# If a Role is removed from a Member, and the Member is also implicitly assigned this Role from an SSO connection
|
540
|
+
# or an SSO group, we will by default revoke any existing sessions for the Member that contain any SSO
|
541
|
+
# authentication factors with the affected connection ID. You can preserve these sessions by passing in the
|
542
|
+
# `preserve_existing_sessions` parameter with a value of `true`.
|
543
|
+
#
|
544
|
+
# If this field is provided, the logged-in Member must have permission to perform the `update.settings.roles` action on the `stytch.member` Resource.
|
545
|
+
# The type of this field is nilable list of +String+.
|
394
546
|
#
|
395
547
|
# == Returns:
|
396
548
|
# An object with the following fields:
|
@@ -409,28 +561,39 @@ module StytchB2B
|
|
409
561
|
# status_code::
|
410
562
|
# The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
|
411
563
|
# The type of this field is +Integer+.
|
564
|
+
#
|
565
|
+
# == Method Options:
|
566
|
+
# This method supports an optional +UpdateRequestOptions+ object which will modify the headers sent in the HTTP request.
|
412
567
|
def update(
|
413
568
|
organization_id:,
|
414
569
|
member_id:,
|
570
|
+
preserve_existing_sessions:,
|
415
571
|
name: nil,
|
416
572
|
trusted_metadata: nil,
|
417
573
|
untrusted_metadata: nil,
|
418
574
|
is_breakglass: nil,
|
419
575
|
mfa_phone_number: nil,
|
420
|
-
mfa_enrolled: nil
|
576
|
+
mfa_enrolled: nil,
|
577
|
+
roles: nil,
|
578
|
+
method_options: nil
|
421
579
|
)
|
422
|
-
|
580
|
+
headers = {}
|
581
|
+
headers = headers.merge(method_options.to_headers) unless method_options.nil?
|
582
|
+
request = {
|
583
|
+
preserve_existing_sessions: preserve_existing_sessions
|
584
|
+
}
|
423
585
|
request[:name] = name unless name.nil?
|
424
586
|
request[:trusted_metadata] = trusted_metadata unless trusted_metadata.nil?
|
425
587
|
request[:untrusted_metadata] = untrusted_metadata unless untrusted_metadata.nil?
|
426
588
|
request[:is_breakglass] = is_breakglass unless is_breakglass.nil?
|
427
589
|
request[:mfa_phone_number] = mfa_phone_number unless mfa_phone_number.nil?
|
428
590
|
request[:mfa_enrolled] = mfa_enrolled unless mfa_enrolled.nil?
|
591
|
+
request[:roles] = roles unless roles.nil?
|
429
592
|
|
430
|
-
put_request("/v1/b2b/organizations/#{organization_id}/members/#{member_id}", request)
|
593
|
+
put_request("/v1/b2b/organizations/#{organization_id}/members/#{member_id}", request, headers)
|
431
594
|
end
|
432
595
|
|
433
|
-
# Deletes a Member specified by `organization_id` and `member_id`.
|
596
|
+
# Deletes a Member specified by `organization_id` and `member_id`. /%}
|
434
597
|
#
|
435
598
|
# == Parameters:
|
436
599
|
# organization_id::
|
@@ -451,14 +614,20 @@ module StytchB2B
|
|
451
614
|
# status_code::
|
452
615
|
# The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
|
453
616
|
# The type of this field is +Integer+.
|
617
|
+
#
|
618
|
+
# == Method Options:
|
619
|
+
# This method supports an optional +DeleteRequestOptions+ object which will modify the headers sent in the HTTP request.
|
454
620
|
def delete(
|
455
621
|
organization_id:,
|
456
|
-
member_id
|
622
|
+
member_id:,
|
623
|
+
method_options: nil
|
457
624
|
)
|
458
|
-
|
625
|
+
headers = {}
|
626
|
+
headers = headers.merge(method_options.to_headers) unless method_options.nil?
|
627
|
+
delete_request("/v1/b2b/organizations/#{organization_id}/members/#{member_id}", headers)
|
459
628
|
end
|
460
629
|
|
461
|
-
# Reactivates a deleted Member's status and its associated email status (if applicable) to active, specified by `organization_id` and `member_id`.
|
630
|
+
# Reactivates a deleted Member's status and its associated email status (if applicable) to active, specified by `organization_id` and `member_id`. /%}
|
462
631
|
#
|
463
632
|
# == Parameters:
|
464
633
|
# organization_id::
|
@@ -485,13 +654,19 @@ module StytchB2B
|
|
485
654
|
# status_code::
|
486
655
|
# The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
|
487
656
|
# The type of this field is +Integer+.
|
657
|
+
#
|
658
|
+
# == Method Options:
|
659
|
+
# This method supports an optional +ReactivateRequestOptions+ object which will modify the headers sent in the HTTP request.
|
488
660
|
def reactivate(
|
489
661
|
organization_id:,
|
490
|
-
member_id
|
662
|
+
member_id:,
|
663
|
+
method_options: nil
|
491
664
|
)
|
665
|
+
headers = {}
|
666
|
+
headers = headers.merge(method_options.to_headers) unless method_options.nil?
|
492
667
|
request = {}
|
493
668
|
|
494
|
-
put_request("/v1/b2b/organizations/#{organization_id}/members/#{member_id}/reactivate", request)
|
669
|
+
put_request("/v1/b2b/organizations/#{organization_id}/members/#{member_id}/reactivate", request, headers)
|
495
670
|
end
|
496
671
|
|
497
672
|
# Delete a Member's MFA phone number.
|
@@ -501,6 +676,7 @@ module StytchB2B
|
|
501
676
|
# Existing Member Sessions that include a phone number authentication factor will not be revoked if the phone number is deleted, and MFA will not be enforced until the Member logs in again.
|
502
677
|
# If you wish to enforce MFA immediately after a phone number is deleted, you can do so by prompting the Member to enter a new phone number
|
503
678
|
# and calling the [OTP SMS send](https://stytch.com/docs/b2b/api/otp-sms-send) endpoint, then calling the [OTP SMS Authenticate](https://stytch.com/docs/b2b/api/authenticate-otp-sms) endpoint.
|
679
|
+
# /%}
|
504
680
|
#
|
505
681
|
# == Parameters:
|
506
682
|
# organization_id::
|
@@ -527,17 +703,35 @@ module StytchB2B
|
|
527
703
|
# status_code::
|
528
704
|
# The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
|
529
705
|
# The type of this field is +Integer+.
|
706
|
+
#
|
707
|
+
# == Method Options:
|
708
|
+
# This method supports an optional +DeleteMFAPhoneNumberRequestOptions+ object which will modify the headers sent in the HTTP request.
|
530
709
|
def delete_mfa_phone_number(
|
531
710
|
organization_id:,
|
532
|
-
member_id
|
711
|
+
member_id:,
|
712
|
+
method_options: nil
|
533
713
|
)
|
534
|
-
|
714
|
+
headers = {}
|
715
|
+
headers = headers.merge(method_options.to_headers) unless method_options.nil?
|
716
|
+
delete_request("/v1/b2b/organizations/#{organization_id}/members/mfa_phone_numbers/#{member_id}", headers)
|
535
717
|
end
|
536
718
|
|
537
719
|
# Search for Members within specified Organizations. An array with at least one `organization_id` is required. Submitting an empty `query` returns all non-deleted Members within the specified Organizations.
|
538
720
|
#
|
539
721
|
# *All fuzzy search filters require a minimum of three characters.
|
540
722
|
#
|
723
|
+
# (Coming Soon) Our RBAC implementation offers out-of-the-box handling of authorization checks for this endpoint. If you pass in
|
724
|
+
# a header containing a `session_token` or a `session_jwt` for an unexpired Member Session, we will check that the
|
725
|
+
# Member Session has permission to perform the `search` action on the `stytch.member` Resource. In addition, enforcing
|
726
|
+
# RBAC on this endpoint means that you may only search for Members within the calling Member's Organization, so the
|
727
|
+
# `organization_ids` argument may only contain the `organization_id` of the Member Session passed in the header.
|
728
|
+
#
|
729
|
+
# If the Member Session does not contain a Role that satisfies the requested permission, or if the `organization_ids`
|
730
|
+
# argument contains an `organization_id` that the Member Session does not belong to, a 403 error will be thrown.
|
731
|
+
# Otherwise, the request will proceed as normal.
|
732
|
+
#
|
733
|
+
# To learn more about our RBAC implementation, see our [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/overview).
|
734
|
+
#
|
541
735
|
# == Parameters:
|
542
736
|
# organization_ids::
|
543
737
|
# An array of organization_ids. At least one value is required.
|
@@ -569,12 +763,18 @@ module StytchB2B
|
|
569
763
|
# status_code::
|
570
764
|
# The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
|
571
765
|
# The type of this field is +Integer+.
|
766
|
+
#
|
767
|
+
# == Method Options:
|
768
|
+
# This method supports an optional +SearchRequestOptions+ object which will modify the headers sent in the HTTP request.
|
572
769
|
def search(
|
573
770
|
organization_ids:,
|
574
771
|
cursor: nil,
|
575
772
|
limit: nil,
|
576
|
-
query: nil
|
773
|
+
query: nil,
|
774
|
+
method_options: nil
|
577
775
|
)
|
776
|
+
headers = {}
|
777
|
+
headers = headers.merge(method_options.to_headers) unless method_options.nil?
|
578
778
|
request = {
|
579
779
|
organization_ids: organization_ids
|
580
780
|
}
|
@@ -582,10 +782,10 @@ module StytchB2B
|
|
582
782
|
request[:limit] = limit unless limit.nil?
|
583
783
|
request[:query] = query unless query.nil?
|
584
784
|
|
585
|
-
post_request('/v1/b2b/organizations/members/search', request)
|
785
|
+
post_request('/v1/b2b/organizations/members/search', request, headers)
|
586
786
|
end
|
587
787
|
|
588
|
-
# Delete a Member's password.
|
788
|
+
# Delete a Member's password. /%}
|
589
789
|
#
|
590
790
|
# == Parameters:
|
591
791
|
# organization_id::
|
@@ -612,14 +812,20 @@ module StytchB2B
|
|
612
812
|
# status_code::
|
613
813
|
# The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
|
614
814
|
# The type of this field is +Integer+.
|
815
|
+
#
|
816
|
+
# == Method Options:
|
817
|
+
# This method supports an optional +DeletePasswordRequestOptions+ object which will modify the headers sent in the HTTP request.
|
615
818
|
def delete_password(
|
616
819
|
organization_id:,
|
617
|
-
member_password_id
|
820
|
+
member_password_id:,
|
821
|
+
method_options: nil
|
618
822
|
)
|
619
|
-
|
823
|
+
headers = {}
|
824
|
+
headers = headers.merge(method_options.to_headers) unless method_options.nil?
|
825
|
+
delete_request("/v1/b2b/organizations/#{organization_id}/members/passwords/#{member_password_id}", headers)
|
620
826
|
end
|
621
827
|
|
622
|
-
# Get a Member by `member_id`. This endpoint does not require an `organization_id`,
|
828
|
+
# Get a Member by `member_id`. This endpoint does not require an `organization_id`, enabling you to get members across organizations. This is a dangerous operation. Incorrect use may open you up to indirect object reference (IDOR) attacks. We recommend using the [Get Member](https://stytch.com/docs/b2b/api/get-member) API instead.
|
623
829
|
#
|
624
830
|
# == Parameters:
|
625
831
|
# member_id::
|
@@ -646,12 +852,13 @@ module StytchB2B
|
|
646
852
|
def dangerously_get(
|
647
853
|
member_id:
|
648
854
|
)
|
855
|
+
headers = {}
|
649
856
|
query_params = {}
|
650
857
|
request = request_with_query_params("/v1/b2b/organizations/members/dangerously_get/#{member_id}", query_params)
|
651
|
-
get_request(request)
|
858
|
+
get_request(request, headers)
|
652
859
|
end
|
653
860
|
|
654
|
-
# Creates a Member. An `organization_id` and `email_address` are required.
|
861
|
+
# Creates a Member. An `organization_id` and `email_address` are required. /%}
|
655
862
|
#
|
656
863
|
# == Parameters:
|
657
864
|
# organization_id::
|
@@ -683,6 +890,10 @@ module StytchB2B
|
|
683
890
|
# mfa_enrolled::
|
684
891
|
# Sets whether the Member is enrolled in MFA. If true, the Member must complete an MFA step whenever they wish to log in to their Organization. If false, the Member only needs to complete an MFA step if the Organization's MFA policy is set to `REQUIRED_FOR_ALL`.
|
685
892
|
# The type of this field is nilable +Boolean+.
|
893
|
+
# roles::
|
894
|
+
# (Coming Soon) Roles to explicitly assign to this Member. See the [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/role-assignment)
|
895
|
+
# for more information about role assignment.
|
896
|
+
# The type of this field is nilable list of +String+.
|
686
897
|
#
|
687
898
|
# == Returns:
|
688
899
|
# An object with the following fields:
|
@@ -701,6 +912,9 @@ module StytchB2B
|
|
701
912
|
# status_code::
|
702
913
|
# The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
|
703
914
|
# The type of this field is +Integer+.
|
915
|
+
#
|
916
|
+
# == Method Options:
|
917
|
+
# This method supports an optional +CreateRequestOptions+ object which will modify the headers sent in the HTTP request.
|
704
918
|
def create(
|
705
919
|
organization_id:,
|
706
920
|
email_address:,
|
@@ -710,8 +924,12 @@ module StytchB2B
|
|
710
924
|
create_member_as_pending: nil,
|
711
925
|
is_breakglass: nil,
|
712
926
|
mfa_phone_number: nil,
|
713
|
-
mfa_enrolled: nil
|
927
|
+
mfa_enrolled: nil,
|
928
|
+
roles: nil,
|
929
|
+
method_options: nil
|
714
930
|
)
|
931
|
+
headers = {}
|
932
|
+
headers = headers.merge(method_options.to_headers) unless method_options.nil?
|
715
933
|
request = {
|
716
934
|
email_address: email_address
|
717
935
|
}
|
@@ -722,8 +940,9 @@ module StytchB2B
|
|
722
940
|
request[:is_breakglass] = is_breakglass unless is_breakglass.nil?
|
723
941
|
request[:mfa_phone_number] = mfa_phone_number unless mfa_phone_number.nil?
|
724
942
|
request[:mfa_enrolled] = mfa_enrolled unless mfa_enrolled.nil?
|
943
|
+
request[:roles] = roles unless roles.nil?
|
725
944
|
|
726
|
-
post_request("/v1/b2b/organizations/#{organization_id}/members", request)
|
945
|
+
post_request("/v1/b2b/organizations/#{organization_id}/members", request, headers)
|
727
946
|
end
|
728
947
|
|
729
948
|
# Get a Member by `member_id` or `email_address`.
|
@@ -761,12 +980,13 @@ module StytchB2B
|
|
761
980
|
member_id: nil,
|
762
981
|
email_address: nil
|
763
982
|
)
|
983
|
+
headers = {}
|
764
984
|
query_params = {
|
765
985
|
member_id: member_id,
|
766
986
|
email_address: email_address
|
767
987
|
}
|
768
988
|
request = request_with_query_params("/v1/b2b/organizations/#{organization_id}/member", query_params)
|
769
|
-
get_request(request)
|
989
|
+
get_request(request, headers)
|
770
990
|
end
|
771
991
|
end
|
772
992
|
end
|