stytch 6.4.0 → 9.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,14 +10,53 @@ require_relative 'request_helper'
10
10
 
11
11
  module StytchB2B
12
12
  class SSO
13
+ class GetConnectionsRequestOptions
14
+ # Optional authorization object.
15
+ # Pass in an active Stytch Member session token or session JWT and the request
16
+ # will be run using that member's permissions.
17
+ attr_accessor :authorization
18
+
19
+ def initialize(
20
+ authorization: nil
21
+ )
22
+ @authorization = authorization
23
+ end
24
+
25
+ def to_headers
26
+ headers = {}
27
+ headers.merge!(@authorization.to_headers) if authorization
28
+ headers
29
+ end
30
+ end
31
+
32
+ class DeleteConnectionRequestOptions
33
+ # Optional authorization object.
34
+ # Pass in an active Stytch Member session token or session JWT and the request
35
+ # will be run using that member's permissions.
36
+ attr_accessor :authorization
37
+
38
+ def initialize(
39
+ authorization: nil
40
+ )
41
+ @authorization = authorization
42
+ end
43
+
44
+ def to_headers
45
+ headers = {}
46
+ headers.merge!(@authorization.to_headers) if authorization
47
+ headers
48
+ end
49
+ end
50
+
13
51
  include Stytch::RequestHelper
14
- attr_reader :oidc, :saml
52
+ attr_reader :oidc, :saml, :external
15
53
 
16
54
  def initialize(connection)
17
55
  @connection = connection
18
56
 
19
57
  @oidc = StytchB2B::SSO::OIDC.new(@connection)
20
58
  @saml = StytchB2B::SSO::SAML.new(@connection)
59
+ @external = StytchB2B::SSO::External.new(@connection)
21
60
  end
22
61
 
23
62
  # Get all SSO Connections owned by the organization.
@@ -38,15 +77,24 @@ module StytchB2B
38
77
  # oidc_connections::
39
78
  # The list of [OIDC Connections](https://stytch.com/docs/b2b/api/oidc-connection-object) owned by this organization.
40
79
  # The type of this field is list of +OIDCConnection+ (+object+).
80
+ # external_connections::
81
+ # The list of [External Connections](https://stytch.com/docs/b2b/api/external-connection-object) owned by this organization.
82
+ # The type of this field is list of +Connection+ (+object+).
41
83
  # status_code::
42
84
  # 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.
43
85
  # The type of this field is +Integer+.
86
+ #
87
+ # == Method Options:
88
+ # This method supports an optional +StytchB2B::SSO::GetConnectionsRequestOptions+ object which will modify the headers sent in the HTTP request.
44
89
  def get_connections(
45
- organization_id:
90
+ organization_id:,
91
+ method_options: nil
46
92
  )
93
+ headers = {}
94
+ headers = headers.merge(method_options.to_headers) unless method_options.nil?
47
95
  query_params = {}
48
96
  request = request_with_query_params("/v1/b2b/sso/#{organization_id}", query_params)
49
- get_request(request)
97
+ get_request(request, headers)
50
98
  end
51
99
 
52
100
  # Delete an existing SSO connection.
@@ -56,7 +104,7 @@ module StytchB2B
56
104
  # The organization ID that the SSO connection belongs to.
57
105
  # The type of this field is +String+.
58
106
  # connection_id::
59
- # The ID of the SSO connection. Both SAML and OIDC connection IDs can be provided.
107
+ # The ID of the SSO connection. SAML, OIDC, and External connection IDs can be provided.
60
108
  # The type of this field is +String+.
61
109
  #
62
110
  # == Returns:
@@ -70,11 +118,17 @@ module StytchB2B
70
118
  # status_code::
71
119
  # 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.
72
120
  # The type of this field is +Integer+.
121
+ #
122
+ # == Method Options:
123
+ # This method supports an optional +StytchB2B::SSO::DeleteConnectionRequestOptions+ object which will modify the headers sent in the HTTP request.
73
124
  def delete_connection(
74
125
  organization_id:,
75
- connection_id:
126
+ connection_id:,
127
+ method_options: nil
76
128
  )
77
- delete_request("/v1/b2b/sso/#{organization_id}/connections/#{connection_id}")
129
+ headers = {}
130
+ headers = headers.merge(method_options.to_headers) unless method_options.nil?
131
+ delete_request("/v1/b2b/sso/#{organization_id}/connections/#{connection_id}", headers)
78
132
  end
79
133
 
80
134
  # Authenticate a user given a token.
@@ -83,8 +137,9 @@ module StytchB2B
83
137
  # If the `session_duration_minutes` parameter is not specified, a Stytch session will be created with a 60 minute duration.
84
138
  # To link this authentication event to an existing Stytch session, include either the `session_token` or `session_jwt` param.
85
139
  #
86
- # If the Member is required to complete MFA to log in to the Organization, the returned value of `member_authenticated` will be `false`, and an `intermediate_session_token` will be returned.
87
- # The `intermediate_session_token` can be passed into the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms) to complete the MFA step and acquire a full member session.
140
+ # If the is required to complete MFA to log in to the, the returned value of `member_authenticated` will be `false`, and an `intermediate_session_token` will be returned.
141
+ # The `intermediate_session_token` can be passed into the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms), [TOTP Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-totp),
142
+ # or [Recovery Codes Recover endpoint](https://stytch.com/docs/b2b/api/recovery-codes-recover) to complete the MFA step and acquire a full member session.
88
143
  # The `session_duration_minutes` and `session_custom_claims` parameters will be ignored.
89
144
  #
90
145
  # If a valid `session_token` or `session_jwt` is passed in, the Member will not be required to complete an MFA step.
@@ -121,7 +176,7 @@ module StytchB2B
121
176
  # Total custom claims size cannot exceed four kilobytes.
122
177
  # The type of this field is nilable +object+.
123
178
  # locale::
124
- # If the Member needs to complete an MFA step, and the Member has a phone number, this endpoint will pre-emptively send a one-time passcode (OTP) to the Member's phone number. The locale argument will be used to determine which language to use when sending the passcode.
179
+ # If the needs to complete an MFA step, and the Member has a phone number, this endpoint will pre-emptively send a one-time passcode (OTP) to the Member's phone number. The locale argument will be used to determine which language to use when sending the passcode.
125
180
  #
126
181
  # Parameter is a [IETF BCP 47 language tag](https://www.w3.org/International/articles/language-tags/), e.g. `"en"`.
127
182
  #
@@ -130,6 +185,9 @@ module StytchB2B
130
185
  # Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")!
131
186
  #
132
187
  # The type of this field is nilable +AuthenticateRequestLocale+ (string enum).
188
+ # intermediate_session_token::
189
+ # Adds this primary authentication factor to the intermediate session token. If the resulting set of factors satisfies the organization's primary authentication requirements and MFA requirements, the intermediate session token will be consumed and converted to a member session. If not, the same intermediate session token will be returned.
190
+ # The type of this field is nilable +String+.
133
191
  #
134
192
  # == Returns:
135
193
  # An object with the following fields:
@@ -159,9 +217,7 @@ module StytchB2B
159
217
  # The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
160
218
  # The type of this field is +Organization+ (+object+).
161
219
  # intermediate_session_token::
162
- # The returned Intermediate Session Token contains an SSO factor associated with the Member.
163
- # The token can be used with the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms) to complete the MFA flow and log in to the Organization.
164
- # SSO factors are not transferable between Organizations, so the intermediate session token is not valid for use with discovery endpoints.
220
+ # The returned Intermediate Session Token contains an SSO factor associated with the Member. If this value is non-empty, the member must complete an MFA step to finish logging in to the Organization. The token can be used with the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms), [TOTP Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-totp), or [Recovery Codes Recover endpoint](https://stytch.com/docs/b2b/api/recovery-codes-recover) to complete an MFA flow and log in to the Organization. SSO factors are not transferable between Organizations, so the intermediate session token is not valid for use with discovery endpoints.
165
221
  # The type of this field is +String+.
166
222
  # member_authenticated::
167
223
  # Indicates whether the Member is fully authenticated. If false, the Member needs to complete an MFA step to log in to the Organization.
@@ -182,8 +238,10 @@ module StytchB2B
182
238
  session_jwt: nil,
183
239
  session_duration_minutes: nil,
184
240
  session_custom_claims: nil,
185
- locale: nil
241
+ locale: nil,
242
+ intermediate_session_token: nil
186
243
  )
244
+ headers = {}
187
245
  request = {
188
246
  sso_token: sso_token
189
247
  }
@@ -193,11 +251,50 @@ module StytchB2B
193
251
  request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
194
252
  request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
195
253
  request[:locale] = locale unless locale.nil?
254
+ request[:intermediate_session_token] = intermediate_session_token unless intermediate_session_token.nil?
196
255
 
197
- post_request('/v1/b2b/sso/authenticate', request)
256
+ post_request('/v1/b2b/sso/authenticate', request, headers)
198
257
  end
199
258
 
200
259
  class OIDC
260
+ class CreateConnectionRequestOptions
261
+ # Optional authorization object.
262
+ # Pass in an active Stytch Member session token or session JWT and the request
263
+ # will be run using that member's permissions.
264
+ attr_accessor :authorization
265
+
266
+ def initialize(
267
+ authorization: nil
268
+ )
269
+ @authorization = authorization
270
+ end
271
+
272
+ def to_headers
273
+ headers = {}
274
+ headers.merge!(@authorization.to_headers) if authorization
275
+ headers
276
+ end
277
+ end
278
+
279
+ class UpdateConnectionRequestOptions
280
+ # Optional authorization object.
281
+ # Pass in an active Stytch Member session token or session JWT and the request
282
+ # will be run using that member's permissions.
283
+ attr_accessor :authorization
284
+
285
+ def initialize(
286
+ authorization: nil
287
+ )
288
+ @authorization = authorization
289
+ end
290
+
291
+ def to_headers
292
+ headers = {}
293
+ headers.merge!(@authorization.to_headers) if authorization
294
+ headers
295
+ end
296
+ end
297
+
201
298
  include Stytch::RequestHelper
202
299
 
203
300
  def initialize(connection)
@@ -213,6 +310,9 @@ module StytchB2B
213
310
  # display_name::
214
311
  # A human-readable display name for the connection.
215
312
  # The type of this field is nilable +String+.
313
+ # identity_provider::
314
+ # The identity provider of this connection. For OIDC, the accepted values are `generic`, `okta`, and `microsoft-entra`. For SAML, the accepted values are `generic`, `okta`, `microsoft-entra`, and `google-workspace`.
315
+ # The type of this field is nilable +CreateConnectionRequestIdentityProvider+ (string enum).
216
316
  #
217
317
  # == Returns:
218
318
  # An object with the following fields:
@@ -225,14 +325,22 @@ module StytchB2B
225
325
  # connection::
226
326
  # The `OIDC Connection` object affected by this API call. See the [OIDC Connection Object](https://stytch.com/docs/b2b/api/oidc-connection-object) for complete response field details.
227
327
  # The type of this field is nilable +OIDCConnection+ (+object+).
328
+ #
329
+ # == Method Options:
330
+ # This method supports an optional +StytchB2B::SSO::OIDC::CreateConnectionRequestOptions+ object which will modify the headers sent in the HTTP request.
228
331
  def create_connection(
229
332
  organization_id:,
230
- display_name: nil
333
+ display_name: nil,
334
+ identity_provider: nil,
335
+ method_options: nil
231
336
  )
337
+ headers = {}
338
+ headers = headers.merge(method_options.to_headers) unless method_options.nil?
232
339
  request = {}
233
340
  request[:display_name] = display_name unless display_name.nil?
341
+ request[:identity_provider] = identity_provider unless identity_provider.nil?
234
342
 
235
- post_request("/v1/b2b/sso/oidc/#{organization_id}", request)
343
+ post_request("/v1/b2b/sso/oidc/#{organization_id}", request, headers)
236
344
  end
237
345
 
238
346
  # Updates an existing OIDC connection.
@@ -285,6 +393,15 @@ module StytchB2B
285
393
  # jwks_url::
286
394
  # The location of the IdP's JSON Web Key Set, used to verify credentials issued by the IdP. This will be provided by the IdP.
287
395
  # The type of this field is nilable +String+.
396
+ # identity_provider::
397
+ # The identity provider of this connection. For OIDC, the accepted values are `generic`, `okta`, and `microsoft-entra`. For SAML, the accepted values are `generic`, `okta`, `microsoft-entra`, and `google-workspace`.
398
+ # The type of this field is nilable +UpdateConnectionRequestIdentityProvider+ (string enum).
399
+ # custom_scopes::
400
+ # Include a space-separated list of custom scopes that you'd like to include. Note that this list must be URL encoded, e.g. the spaces must be expressed as %20.
401
+ # The type of this field is nilable +String+.
402
+ # attribute_mapping::
403
+ # An object that represents the attributes used to identify a Member. This object will map the IdP-defined User attributes to Stytch-specific values, which will appear on the member's Trusted Metadata.
404
+ # The type of this field is nilable +object+.
288
405
  #
289
406
  # == Returns:
290
407
  # An object with the following fields:
@@ -300,6 +417,9 @@ module StytchB2B
300
417
  # warning::
301
418
  # If it is not possible to resolve the well-known metadata document from the OIDC issuer, this field will explain what went wrong if the request is successful otherwise. In other words, even if the overall request succeeds, there could be relevant warnings related to the connection update.
302
419
  # The type of this field is nilable +String+.
420
+ #
421
+ # == Method Options:
422
+ # This method supports an optional +StytchB2B::SSO::OIDC::UpdateConnectionRequestOptions+ object which will modify the headers sent in the HTTP request.
303
423
  def update_connection(
304
424
  organization_id:,
305
425
  connection_id:,
@@ -310,8 +430,14 @@ module StytchB2B
310
430
  authorization_url: nil,
311
431
  token_url: nil,
312
432
  userinfo_url: nil,
313
- jwks_url: nil
433
+ jwks_url: nil,
434
+ identity_provider: nil,
435
+ custom_scopes: nil,
436
+ attribute_mapping: nil,
437
+ method_options: nil
314
438
  )
439
+ headers = {}
440
+ headers = headers.merge(method_options.to_headers) unless method_options.nil?
315
441
  request = {}
316
442
  request[:display_name] = display_name unless display_name.nil?
317
443
  request[:client_id] = client_id unless client_id.nil?
@@ -321,12 +447,91 @@ module StytchB2B
321
447
  request[:token_url] = token_url unless token_url.nil?
322
448
  request[:userinfo_url] = userinfo_url unless userinfo_url.nil?
323
449
  request[:jwks_url] = jwks_url unless jwks_url.nil?
450
+ request[:identity_provider] = identity_provider unless identity_provider.nil?
451
+ request[:custom_scopes] = custom_scopes unless custom_scopes.nil?
452
+ request[:attribute_mapping] = attribute_mapping unless attribute_mapping.nil?
324
453
 
325
- put_request("/v1/b2b/sso/oidc/#{organization_id}/connections/#{connection_id}", request)
454
+ put_request("/v1/b2b/sso/oidc/#{organization_id}/connections/#{connection_id}", request, headers)
326
455
  end
327
456
  end
328
457
 
329
458
  class SAML
459
+ class CreateConnectionRequestOptions
460
+ # Optional authorization object.
461
+ # Pass in an active Stytch Member session token or session JWT and the request
462
+ # will be run using that member's permissions.
463
+ attr_accessor :authorization
464
+
465
+ def initialize(
466
+ authorization: nil
467
+ )
468
+ @authorization = authorization
469
+ end
470
+
471
+ def to_headers
472
+ headers = {}
473
+ headers.merge!(@authorization.to_headers) if authorization
474
+ headers
475
+ end
476
+ end
477
+
478
+ class UpdateConnectionRequestOptions
479
+ # Optional authorization object.
480
+ # Pass in an active Stytch Member session token or session JWT and the request
481
+ # will be run using that member's permissions.
482
+ attr_accessor :authorization
483
+
484
+ def initialize(
485
+ authorization: nil
486
+ )
487
+ @authorization = authorization
488
+ end
489
+
490
+ def to_headers
491
+ headers = {}
492
+ headers.merge!(@authorization.to_headers) if authorization
493
+ headers
494
+ end
495
+ end
496
+
497
+ class UpdateByURLRequestOptions
498
+ # Optional authorization object.
499
+ # Pass in an active Stytch Member session token or session JWT and the request
500
+ # will be run using that member's permissions.
501
+ attr_accessor :authorization
502
+
503
+ def initialize(
504
+ authorization: nil
505
+ )
506
+ @authorization = authorization
507
+ end
508
+
509
+ def to_headers
510
+ headers = {}
511
+ headers.merge!(@authorization.to_headers) if authorization
512
+ headers
513
+ end
514
+ end
515
+
516
+ class DeleteVerificationCertificateRequestOptions
517
+ # Optional authorization object.
518
+ # Pass in an active Stytch Member session token or session JWT and the request
519
+ # will be run using that member's permissions.
520
+ attr_accessor :authorization
521
+
522
+ def initialize(
523
+ authorization: nil
524
+ )
525
+ @authorization = authorization
526
+ end
527
+
528
+ def to_headers
529
+ headers = {}
530
+ headers.merge!(@authorization.to_headers) if authorization
531
+ headers
532
+ end
533
+ end
534
+
330
535
  include Stytch::RequestHelper
331
536
 
332
537
  def initialize(connection)
@@ -342,6 +547,9 @@ module StytchB2B
342
547
  # display_name::
343
548
  # A human-readable display name for the connection.
344
549
  # The type of this field is nilable +String+.
550
+ # identity_provider::
551
+ # The identity provider of this connection. For OIDC, the accepted values are `generic`, `okta`, and `microsoft-entra`. For SAML, the accepted values are `generic`, `okta`, `microsoft-entra`, and `google-workspace`.
552
+ # The type of this field is nilable +CreateConnectionRequestIdentityProvider+ (string enum).
345
553
  #
346
554
  # == Returns:
347
555
  # An object with the following fields:
@@ -354,14 +562,22 @@ module StytchB2B
354
562
  # connection::
355
563
  # The `SAML Connection` object affected by this API call. See the [SAML Connection Object](https://stytch.com/docs/b2b/api/saml-connection-object) for complete response field details.
356
564
  # The type of this field is nilable +SAMLConnection+ (+object+).
565
+ #
566
+ # == Method Options:
567
+ # This method supports an optional +StytchB2B::SSO::SAML::CreateConnectionRequestOptions+ object which will modify the headers sent in the HTTP request.
357
568
  def create_connection(
358
569
  organization_id:,
359
- display_name: nil
570
+ display_name: nil,
571
+ identity_provider: nil,
572
+ method_options: nil
360
573
  )
574
+ headers = {}
575
+ headers = headers.merge(method_options.to_headers) unless method_options.nil?
361
576
  request = {}
362
577
  request[:display_name] = display_name unless display_name.nil?
578
+ request[:identity_provider] = identity_provider unless identity_provider.nil?
363
579
 
364
- post_request("/v1/b2b/sso/saml/#{organization_id}", request)
580
+ post_request("/v1/b2b/sso/saml/#{organization_id}", request, headers)
365
581
  end
366
582
 
367
583
  # Updates an existing SAML connection.
@@ -394,6 +610,23 @@ module StytchB2B
394
610
  # idp_sso_url::
395
611
  # The URL for which assertions for login requests will be sent. This will be provided by the IdP.
396
612
  # The type of this field is nilable +String+.
613
+ # saml_connection_implicit_role_assignments::
614
+ # All Members who log in with this SAML connection will implicitly receive the specified Roles. See the [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/role-assignment) for more information about role assignment.
615
+ # The type of this field is nilable list of +SAMLConnectionImplicitRoleAssignment+.
616
+ # saml_group_implicit_role_assignments::
617
+ # Defines the names of the SAML groups
618
+ # that grant specific role assignments. For each group-Role pair, if a Member logs in with this SAML connection and
619
+ # belongs to the specified SAML group, they will be granted the associated Role. See the
620
+ # [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/role-assignment) for more information about role assignment.
621
+ # Before adding any group implicit role assignments, you must add a "groups" key to your SAML connection's
622
+ # `attribute_mapping`. Make sure that your IdP is configured to correctly send the group information.
623
+ # The type of this field is nilable list of +SAMLGroupImplicitRoleAssignment+.
624
+ # alternative_audience_uri::
625
+ # An alternative URL to use for the Audience Restriction. This value can be used when you wish to migrate an existing SAML integration to Stytch with zero downtime. Read our [SSO migration guide](https://stytch.com/docs/b2b/guides/migrations/additional-migration-considerations) for more info.
626
+ # The type of this field is nilable +String+.
627
+ # identity_provider::
628
+ # The identity provider of this connection. For OIDC, the accepted values are `generic`, `okta`, and `microsoft-entra`. For SAML, the accepted values are `generic`, `okta`, `microsoft-entra`, and `google-workspace`.
629
+ # The type of this field is nilable +UpdateConnectionRequestIdentityProvider+ (string enum).
397
630
  #
398
631
  # == Returns:
399
632
  # An object with the following fields:
@@ -406,6 +639,9 @@ module StytchB2B
406
639
  # connection::
407
640
  # The `SAML Connection` object affected by this API call. See the [SAML Connection Object](https://stytch.com/docs/b2b/api/saml-connection-object) for complete response field details.
408
641
  # The type of this field is nilable +SAMLConnection+ (+object+).
642
+ #
643
+ # == Method Options:
644
+ # This method supports an optional +StytchB2B::SSO::SAML::UpdateConnectionRequestOptions+ object which will modify the headers sent in the HTTP request.
409
645
  def update_connection(
410
646
  organization_id:,
411
647
  connection_id:,
@@ -413,16 +649,75 @@ module StytchB2B
413
649
  display_name: nil,
414
650
  attribute_mapping: nil,
415
651
  x509_certificate: nil,
416
- idp_sso_url: nil
652
+ idp_sso_url: nil,
653
+ saml_connection_implicit_role_assignments: nil,
654
+ saml_group_implicit_role_assignments: nil,
655
+ alternative_audience_uri: nil,
656
+ identity_provider: nil,
657
+ method_options: nil
417
658
  )
659
+ headers = {}
660
+ headers = headers.merge(method_options.to_headers) unless method_options.nil?
418
661
  request = {}
419
662
  request[:idp_entity_id] = idp_entity_id unless idp_entity_id.nil?
420
663
  request[:display_name] = display_name unless display_name.nil?
421
664
  request[:attribute_mapping] = attribute_mapping unless attribute_mapping.nil?
422
665
  request[:x509_certificate] = x509_certificate unless x509_certificate.nil?
423
666
  request[:idp_sso_url] = idp_sso_url unless idp_sso_url.nil?
667
+ request[:saml_connection_implicit_role_assignments] = saml_connection_implicit_role_assignments unless saml_connection_implicit_role_assignments.nil?
668
+ request[:saml_group_implicit_role_assignments] = saml_group_implicit_role_assignments unless saml_group_implicit_role_assignments.nil?
669
+ request[:alternative_audience_uri] = alternative_audience_uri unless alternative_audience_uri.nil?
670
+ request[:identity_provider] = identity_provider unless identity_provider.nil?
424
671
 
425
- put_request("/v1/b2b/sso/saml/#{organization_id}/connections/#{connection_id}", request)
672
+ put_request("/v1/b2b/sso/saml/#{organization_id}/connections/#{connection_id}", request, headers)
673
+ end
674
+
675
+ # Used to update an existing SAML connection using an IDP metadata URL.
676
+ #
677
+ # A newly created connection will not become active until all the following are provided:
678
+ # * `idp_sso_url`
679
+ # * `idp_entity_id`
680
+ # * `x509_certificate`
681
+ # * `attribute_mapping` (must be supplied using [Update SAML Connection](update-saml-connection))
682
+ #
683
+ # == Parameters:
684
+ # organization_id::
685
+ # 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.
686
+ # The type of this field is +String+.
687
+ # connection_id::
688
+ # Globally unique UUID that identifies a specific SSO `connection_id` for a Member.
689
+ # The type of this field is +String+.
690
+ # metadata_url::
691
+ # A URL that points to the IdP metadata. This will be provided by the IdP.
692
+ # The type of this field is +String+.
693
+ #
694
+ # == Returns:
695
+ # An object with the following fields:
696
+ # request_id::
697
+ # Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
698
+ # The type of this field is +String+.
699
+ # status_code::
700
+ # 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.
701
+ # The type of this field is +Integer+.
702
+ # connection::
703
+ # The `SAML Connection` object affected by this API call. See the [SAML Connection Object](https://stytch.com/docs/b2b/api/saml-connection-object) for complete response field details.
704
+ # The type of this field is nilable +SAMLConnection+ (+object+).
705
+ #
706
+ # == Method Options:
707
+ # This method supports an optional +StytchB2B::SSO::SAML::UpdateByURLRequestOptions+ object which will modify the headers sent in the HTTP request.
708
+ def update_by_url(
709
+ organization_id:,
710
+ connection_id:,
711
+ metadata_url:,
712
+ method_options: nil
713
+ )
714
+ headers = {}
715
+ headers = headers.merge(method_options.to_headers) unless method_options.nil?
716
+ request = {
717
+ metadata_url: metadata_url
718
+ }
719
+
720
+ put_request("/v1/b2b/sso/saml/#{organization_id}/connections/#{connection_id}/url", request, headers)
426
721
  end
427
722
 
428
723
  # Delete a SAML verification certificate.
@@ -451,12 +746,179 @@ module StytchB2B
451
746
  # status_code::
452
747
  # 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
748
  # The type of this field is +Integer+.
749
+ #
750
+ # == Method Options:
751
+ # This method supports an optional +StytchB2B::SSO::SAML::DeleteVerificationCertificateRequestOptions+ object which will modify the headers sent in the HTTP request.
454
752
  def delete_verification_certificate(
455
753
  organization_id:,
456
754
  connection_id:,
457
- certificate_id:
755
+ certificate_id:,
756
+ method_options: nil
458
757
  )
459
- delete_request("/v1/b2b/sso/saml/#{organization_id}/connections/#{connection_id}/verification_certificates/#{certificate_id}")
758
+ headers = {}
759
+ headers = headers.merge(method_options.to_headers) unless method_options.nil?
760
+ delete_request("/v1/b2b/sso/saml/#{organization_id}/connections/#{connection_id}/verification_certificates/#{certificate_id}", headers)
761
+ end
762
+ end
763
+
764
+ class External
765
+ class CreateConnectionRequestOptions
766
+ # Optional authorization object.
767
+ # Pass in an active Stytch Member session token or session JWT and the request
768
+ # will be run using that member's permissions.
769
+ attr_accessor :authorization
770
+
771
+ def initialize(
772
+ authorization: nil
773
+ )
774
+ @authorization = authorization
775
+ end
776
+
777
+ def to_headers
778
+ headers = {}
779
+ headers.merge!(@authorization.to_headers) if authorization
780
+ headers
781
+ end
782
+ end
783
+
784
+ class UpdateConnectionRequestOptions
785
+ # Optional authorization object.
786
+ # Pass in an active Stytch Member session token or session JWT and the request
787
+ # will be run using that member's permissions.
788
+ attr_accessor :authorization
789
+
790
+ def initialize(
791
+ authorization: nil
792
+ )
793
+ @authorization = authorization
794
+ end
795
+
796
+ def to_headers
797
+ headers = {}
798
+ headers.merge!(@authorization.to_headers) if authorization
799
+ headers
800
+ end
801
+ end
802
+
803
+ include Stytch::RequestHelper
804
+
805
+ def initialize(connection)
806
+ @connection = connection
807
+ end
808
+
809
+ # Create a new External SSO Connection.
810
+ #
811
+ # == Parameters:
812
+ # organization_id::
813
+ # 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.
814
+ # The type of this field is +String+.
815
+ # external_organization_id::
816
+ # Globally unique UUID that identifies a different Organization within your Project.
817
+ # The type of this field is +String+.
818
+ # external_connection_id::
819
+ # Globally unique UUID that identifies a specific SSO connection configured for a different Organization in your Project.
820
+ # The type of this field is +String+.
821
+ # display_name::
822
+ # A human-readable display name for the connection.
823
+ # The type of this field is nilable +String+.
824
+ # connection_implicit_role_assignments::
825
+ # (no documentation yet)
826
+ # The type of this field is nilable list of +SAMLConnectionImplicitRoleAssignment+.
827
+ # group_implicit_role_assignments::
828
+ # (no documentation yet)
829
+ # The type of this field is nilable list of +SAMLGroupImplicitRoleAssignment+.
830
+ #
831
+ # == Returns:
832
+ # An object with the following fields:
833
+ # request_id::
834
+ # Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
835
+ # The type of this field is +String+.
836
+ # status_code::
837
+ # 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.
838
+ # The type of this field is +Integer+.
839
+ # connection::
840
+ # The `External Connection` object affected by this API call. See the [External Connection Object](https://stytch.com/docs/b2b/api/external-connection-object) for complete response field details.
841
+ # The type of this field is nilable +Connection+ (+object+).
842
+ #
843
+ # == Method Options:
844
+ # This method supports an optional +StytchB2B::SSO::External::CreateConnectionRequestOptions+ object which will modify the headers sent in the HTTP request.
845
+ def create_connection(
846
+ organization_id:,
847
+ external_organization_id:,
848
+ external_connection_id:,
849
+ display_name: nil,
850
+ connection_implicit_role_assignments: nil,
851
+ group_implicit_role_assignments: nil,
852
+ method_options: nil
853
+ )
854
+ headers = {}
855
+ headers = headers.merge(method_options.to_headers) unless method_options.nil?
856
+ request = {
857
+ external_organization_id: external_organization_id,
858
+ external_connection_id: external_connection_id
859
+ }
860
+ request[:display_name] = display_name unless display_name.nil?
861
+ request[:connection_implicit_role_assignments] = connection_implicit_role_assignments unless connection_implicit_role_assignments.nil?
862
+ request[:group_implicit_role_assignments] = group_implicit_role_assignments unless group_implicit_role_assignments.nil?
863
+
864
+ post_request("/v1/b2b/sso/external/#{organization_id}", request, headers)
865
+ end
866
+
867
+ # Updates an existing External SSO connection.
868
+ #
869
+ # == Parameters:
870
+ # organization_id::
871
+ # 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.
872
+ # The type of this field is +String+.
873
+ # connection_id::
874
+ # Globally unique UUID that identifies a specific External SSO Connection.
875
+ # The type of this field is +String+.
876
+ # display_name::
877
+ # A human-readable display name for the connection.
878
+ # The type of this field is nilable +String+.
879
+ # external_connection_implicit_role_assignments::
880
+ # All Members who log in with this External connection will implicitly receive the specified Roles. See the [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/role-assignment) for more information about role assignment.Implicit role assignments are not supported for External connections if the underlying SSO connection is an OIDC connection.
881
+ # The type of this field is nilable list of +ConnectionImplicitRoleAssignment+.
882
+ # external_group_implicit_role_assignments::
883
+ # Defines the names of the groups
884
+ # that grant specific role assignments. For each group-Role pair, if a Member logs in with this external connection and
885
+ # belongs to the specified group, they will be granted the associated Role. See the
886
+ # [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/role-assignment) for more information about role assignment.
887
+ # Before adding any group implicit role assignments to an external connection, you must add a "groups" key to the underlying SAML connection's
888
+ # `attribute_mapping`. Make sure that the SAML connection IdP is configured to correctly send the group information. Implicit role assignments are not supported
889
+ # for External connections if the underlying SSO connection is an OIDC connection.
890
+ # The type of this field is nilable list of +GroupImplicitRoleAssignment+.
891
+ #
892
+ # == Returns:
893
+ # An object with the following fields:
894
+ # request_id::
895
+ # Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
896
+ # The type of this field is +String+.
897
+ # status_code::
898
+ # 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.
899
+ # The type of this field is +Integer+.
900
+ # connection::
901
+ # The `External Connection` object affected by this API call. See the [External Connection Object](https://stytch.com/docs/b2b/api/external-connection-object) for complete response field details.
902
+ # The type of this field is nilable +Connection+ (+object+).
903
+ #
904
+ # == Method Options:
905
+ # This method supports an optional +StytchB2B::SSO::External::UpdateConnectionRequestOptions+ object which will modify the headers sent in the HTTP request.
906
+ def update_connection(
907
+ organization_id:,
908
+ connection_id:,
909
+ display_name: nil,
910
+ external_connection_implicit_role_assignments: nil,
911
+ external_group_implicit_role_assignments: nil,
912
+ method_options: nil
913
+ )
914
+ headers = {}
915
+ headers = headers.merge(method_options.to_headers) unless method_options.nil?
916
+ request = {}
917
+ request[:display_name] = display_name unless display_name.nil?
918
+ request[:external_connection_implicit_role_assignments] = external_connection_implicit_role_assignments unless external_connection_implicit_role_assignments.nil?
919
+ request[:external_group_implicit_role_assignments] = external_group_implicit_role_assignments unless external_group_implicit_role_assignments.nil?
920
+
921
+ put_request("/v1/b2b/sso/external/#{organization_id}/connections/#{connection_id}", request, headers)
460
922
  end
461
923
  end
462
924
  end