# frozen_string_literal: true # !!! # WARNING: This file is autogenerated # Only modify code within MANUAL() sections # or your changes may be overwritten later! # !!! require_relative 'request_helper' module StytchB2B class SSO class GetConnectionsRequestOptions # Optional authorization object. # Pass in an active Stytch Member session token or session JWT and the request # will be run using that member's permissions. attr_accessor :authorization def initialize( authorization: nil ) @authorization = authorization end def to_headers headers = {} headers.merge!(@authorization.to_headers) if authorization headers end end class DeleteConnectionRequestOptions # Optional authorization object. # Pass in an active Stytch Member session token or session JWT and the request # will be run using that member's permissions. attr_accessor :authorization def initialize( authorization: nil ) @authorization = authorization end def to_headers headers = {} headers.merge!(@authorization.to_headers) if authorization headers end end include Stytch::RequestHelper attr_reader :oidc, :saml, :external def initialize(connection) @connection = connection @oidc = StytchB2B::SSO::OIDC.new(@connection) @saml = StytchB2B::SSO::SAML.new(@connection) @external = StytchB2B::SSO::External.new(@connection) end # Get all SSO Connections owned by the organization. # # == Parameters: # organization_id:: # 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. # The type of this field is +String+. # # == Returns: # An object with the following fields: # request_id:: # 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. # The type of this field is +String+. # saml_connections:: # The list of [SAML Connections](https://stytch.com/docs/b2b/api/saml-connection-object) owned by this organization. # The type of this field is list of +SAMLConnection+ (+object+). # oidc_connections:: # The list of [OIDC Connections](https://stytch.com/docs/b2b/api/oidc-connection-object) owned by this organization. # The type of this field is list of +OIDCConnection+ (+object+). # external_connections:: # The list of [External Connections](https://stytch.com/docs/b2b/api/external-connection-object) owned by this organization. # The type of this field is list of +Connection+ (+object+). # status_code:: # 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. # The type of this field is +Integer+. # # == Method Options: # This method supports an optional +StytchB2B::SSO::GetConnectionsRequestOptions+ object which will modify the headers sent in the HTTP request. def get_connections( organization_id:, method_options: nil ) headers = {} headers = headers.merge(method_options.to_headers) unless method_options.nil? query_params = {} request = request_with_query_params("/v1/b2b/sso/#{organization_id}", query_params) get_request(request, headers) end # Delete an existing SSO connection. # # == Parameters: # organization_id:: # The organization ID that the SSO connection belongs to. # The type of this field is +String+. # connection_id:: # The ID of the SSO connection. SAML, OIDC, and External connection IDs can be provided. # The type of this field is +String+. # # == Returns: # An object with the following fields: # request_id:: # 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. # The type of this field is +String+. # connection_id:: # The `connection_id` that was deleted as part of the delete request. # The type of this field is +String+. # status_code:: # 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. # The type of this field is +Integer+. # # == Method Options: # This method supports an optional +StytchB2B::SSO::DeleteConnectionRequestOptions+ object which will modify the headers sent in the HTTP request. def delete_connection( organization_id:, connection_id:, method_options: nil ) headers = {} headers = headers.merge(method_options.to_headers) unless method_options.nil? delete_request("/v1/b2b/sso/#{organization_id}/connections/#{connection_id}", headers) end # Authenticate a user given a token. # This endpoint verifies that the user completed the SSO Authentication flow by verifying that the token is valid and hasn't expired. # Provide the `session_duration_minutes` parameter to set the lifetime of the session. # If the `session_duration_minutes` parameter is not specified, a Stytch session will be created with a 60 minute duration. # To link this authentication event to an existing Stytch session, include either the `session_token` or `session_jwt` param. # # 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. # 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), # 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. # The `session_duration_minutes` and `session_custom_claims` parameters will be ignored. # # If a valid `session_token` or `session_jwt` is passed in, the Member will not be required to complete an MFA step. # # == Parameters: # sso_token:: # The token to authenticate. # The type of this field is +String+. # pkce_code_verifier:: # A base64url encoded one time secret used to validate that the request starts and ends on the same device. # The type of this field is nilable +String+. # session_token:: # The `session_token` belonging to the member that you wish to associate the email with. # The type of this field is nilable +String+. # session_jwt:: # The `session_jwt` belonging to the member that you wish to associate the email with. # The type of this field is nilable +String+. # session_duration_minutes:: # Set the session lifetime to be this many minutes from now. This will start a new session if one doesn't already exist, # returning both an opaque `session_token` and `session_jwt` for this session. Remember that the `session_jwt` will have a fixed lifetime of # five minutes regardless of the underlying session duration, and will need to be refreshed over time. # # This value must be a minimum of 5 and a maximum of 527040 minutes (366 days). # # If a `session_token` or `session_jwt` is provided then a successful authentication will continue to extend the session this many minutes. # # If the `session_duration_minutes` parameter is not specified, a Stytch session will be created with a 60 minute duration. If you don't want # to use the Stytch session product, you can ignore the session fields in the response. # The type of this field is nilable +Integer+. # session_custom_claims:: # Add a custom claims map to the Session being authenticated. Claims are only created if a Session is initialized by providing a value in # `session_duration_minutes`. Claims will be included on the Session object and in the JWT. To update a key in an existing Session, supply a new value. To # delete a key, supply a null value. Custom claims made with reserved claims (`iss`, `sub`, `aud`, `exp`, `nbf`, `iat`, `jti`) will be ignored. # Total custom claims size cannot exceed four kilobytes. # The type of this field is nilable +object+. # locale:: # 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. # # Parameter is a [IETF BCP 47 language tag](https://www.w3.org/International/articles/language-tags/), e.g. `"en"`. # # Currently supported languages are English (`"en"`), Spanish (`"es"`), and Brazilian Portuguese (`"pt-br"`); if no value is provided, the copy defaults to English. # # Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")! # # The type of this field is nilable +AuthenticateRequestLocale+ (string enum). # intermediate_session_token:: # 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. # The type of this field is nilable +String+. # # == Returns: # An object with the following fields: # request_id:: # 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. # The type of this field is +String+. # member_id:: # Globally unique UUID that identifies a specific Member. # The type of this field is +String+. # organization_id:: # 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. # The type of this field is +String+. # member:: # The [Member object](https://stytch.com/docs/b2b/api/member-object) # The type of this field is +Member+ (+object+). # session_token:: # A secret token for a given Stytch Session. # The type of this field is +String+. # session_jwt:: # The JSON Web Token (JWT) for a given Stytch Session. # The type of this field is +String+. # reset_session:: # Indicates if all Sessions linked to the Member need to be reset. You should check this field if you aren't using # Stytch's Session product. If you are using Stytch's Session product, we revoke the Member’s other Sessions for you. # The type of this field is +Boolean+. # organization:: # The [Organization object](https://stytch.com/docs/b2b/api/organization-object). # The type of this field is +Organization+ (+object+). # intermediate_session_token:: # 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. # The type of this field is +String+. # member_authenticated:: # Indicates whether the Member is fully authenticated. If false, the Member needs to complete an MFA step to log in to the Organization. # The type of this field is +Boolean+. # status_code:: # 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. # The type of this field is +Integer+. # member_session:: # The [Session object](https://stytch.com/docs/b2b/api/session-object). # The type of this field is nilable +MemberSession+ (+object+). # mfa_required:: # Information about the MFA requirements of the Organization and the Member's options for fulfilling MFA. # The type of this field is nilable +MfaRequired+ (+object+). def authenticate( sso_token:, pkce_code_verifier: nil, session_token: nil, session_jwt: nil, session_duration_minutes: nil, session_custom_claims: nil, locale: nil, intermediate_session_token: nil ) headers = {} request = { sso_token: sso_token } request[:pkce_code_verifier] = pkce_code_verifier unless pkce_code_verifier.nil? request[:session_token] = session_token unless session_token.nil? request[:session_jwt] = session_jwt unless session_jwt.nil? request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil? request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil? request[:locale] = locale unless locale.nil? request[:intermediate_session_token] = intermediate_session_token unless intermediate_session_token.nil? post_request('/v1/b2b/sso/authenticate', request, headers) end class OIDC class CreateConnectionRequestOptions # Optional authorization object. # Pass in an active Stytch Member session token or session JWT and the request # will be run using that member's permissions. attr_accessor :authorization def initialize( authorization: nil ) @authorization = authorization end def to_headers headers = {} headers.merge!(@authorization.to_headers) if authorization headers end end class UpdateConnectionRequestOptions # Optional authorization object. # Pass in an active Stytch Member session token or session JWT and the request # will be run using that member's permissions. attr_accessor :authorization def initialize( authorization: nil ) @authorization = authorization end def to_headers headers = {} headers.merge!(@authorization.to_headers) if authorization headers end end include Stytch::RequestHelper def initialize(connection) @connection = connection end # Create a new OIDC Connection. # # == Parameters: # organization_id:: # 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. # The type of this field is +String+. # display_name:: # A human-readable display name for the connection. # The type of this field is nilable +String+. # identity_provider:: # Name of the IdP. Enum with possible values: `classlink`, `cyberark`, `duo`, `google-workspace`, `jumpcloud`, `keycloak`, `miniorange`, `microsoft-entra`, `okta`, `onelogin`, `pingfederate`, `rippling`, `salesforce`, `shibboleth`, or `generic`. # # Specifying a known provider allows Stytch to handle any provider-specific logic. # The type of this field is nilable +CreateConnectionRequestIdentityProvider+ (string enum). # # == Returns: # An object with the following fields: # request_id:: # 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. # The type of this field is +String+. # status_code:: # 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. # The type of this field is +Integer+. # connection:: # 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. # The type of this field is nilable +OIDCConnection+ (+object+). # # == Method Options: # This method supports an optional +StytchB2B::SSO::OIDC::CreateConnectionRequestOptions+ object which will modify the headers sent in the HTTP request. def create_connection( organization_id:, display_name: nil, identity_provider: nil, method_options: nil ) headers = {} headers = headers.merge(method_options.to_headers) unless method_options.nil? request = {} request[:display_name] = display_name unless display_name.nil? request[:identity_provider] = identity_provider unless identity_provider.nil? post_request("/v1/b2b/sso/oidc/#{organization_id}", request, headers) end # Updates an existing OIDC connection. # # When the value of `issuer` changes, Stytch will attempt to retrieve the [OpenID Provider Metadata](https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata) document found at `$/.well-known/openid-configuration`. # If the metadata document can be retrieved successfully, Stytch will use it to infer the values of `authorization_url`, `token_url`, `jwks_url`, and `userinfo_url`. # The `client_id` and `client_secret` values cannot be inferred from the metadata document, and *must* be passed in explicitly. # # If the metadata document cannot be retrieved, Stytch will still update the connection using values from the request body. # # If the metadata document can be retrieved, and values are passed in the request body, the explicit values passed in from the request body will take precedence over the values inferred from the metadata document. # # Note that a newly created connection will not become active until all of the following fields are provided: # * `issuer` # * `client_id` # * `client_secret` # * `authorization_url` # * `token_url` # * `userinfo_url` # * `jwks_url` # # == Parameters: # organization_id:: # 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. # The type of this field is +String+. # connection_id:: # Globally unique UUID that identifies a specific SSO `connection_id` for a Member. # The type of this field is +String+. # display_name:: # A human-readable display name for the connection. # The type of this field is nilable +String+. # client_id:: # The OAuth2.0 client ID used to authenticate login attempts. This will be provided by the IdP. # The type of this field is nilable +String+. # client_secret:: # The secret belonging to the OAuth2.0 client used to authenticate login attempts. This will be provided by the IdP. # The type of this field is nilable +String+. # issuer:: # A case-sensitive `https://` URL that uniquely identifies the IdP. This will be provided by the IdP. # The type of this field is nilable +String+. # authorization_url:: # The location of the URL that starts an OAuth login at the IdP. This will be provided by the IdP. # The type of this field is nilable +String+. # token_url:: # The location of the URL that issues OAuth2.0 access tokens and OIDC ID tokens. This will be provided by the IdP. # The type of this field is nilable +String+. # userinfo_url:: # The location of the IDP's [UserInfo Endpoint](https://openid.net/specs/openid-connect-core-1_0.html#UserInfo). This will be provided by the IdP. # The type of this field is nilable +String+. # jwks_url:: # 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. # The type of this field is nilable +String+. # identity_provider:: # Name of the IdP. Enum with possible values: `classlink`, `cyberark`, `duo`, `google-workspace`, `jumpcloud`, `keycloak`, `miniorange`, `microsoft-entra`, `okta`, `onelogin`, `pingfederate`, `rippling`, `salesforce`, `shibboleth`, or `generic`. # # Specifying a known provider allows Stytch to handle any provider-specific logic. # The type of this field is nilable +UpdateConnectionRequestIdentityProvider+ (string enum). # custom_scopes:: # 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. # The type of this field is nilable +String+. # attribute_mapping:: # 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. # The type of this field is nilable +object+. # # == Returns: # An object with the following fields: # request_id:: # 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. # The type of this field is +String+. # status_code:: # 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. # The type of this field is +Integer+. # connection:: # 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. # The type of this field is nilable +OIDCConnection+ (+object+). # warning:: # 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. # The type of this field is nilable +String+. # # == Method Options: # This method supports an optional +StytchB2B::SSO::OIDC::UpdateConnectionRequestOptions+ object which will modify the headers sent in the HTTP request. def update_connection( organization_id:, connection_id:, display_name: nil, client_id: nil, client_secret: nil, issuer: nil, authorization_url: nil, token_url: nil, userinfo_url: nil, jwks_url: nil, identity_provider: nil, custom_scopes: nil, attribute_mapping: nil, method_options: nil ) headers = {} headers = headers.merge(method_options.to_headers) unless method_options.nil? request = {} request[:display_name] = display_name unless display_name.nil? request[:client_id] = client_id unless client_id.nil? request[:client_secret] = client_secret unless client_secret.nil? request[:issuer] = issuer unless issuer.nil? request[:authorization_url] = authorization_url unless authorization_url.nil? request[:token_url] = token_url unless token_url.nil? request[:userinfo_url] = userinfo_url unless userinfo_url.nil? request[:jwks_url] = jwks_url unless jwks_url.nil? request[:identity_provider] = identity_provider unless identity_provider.nil? request[:custom_scopes] = custom_scopes unless custom_scopes.nil? request[:attribute_mapping] = attribute_mapping unless attribute_mapping.nil? put_request("/v1/b2b/sso/oidc/#{organization_id}/connections/#{connection_id}", request, headers) end end class SAML class CreateConnectionRequestOptions # Optional authorization object. # Pass in an active Stytch Member session token or session JWT and the request # will be run using that member's permissions. attr_accessor :authorization def initialize( authorization: nil ) @authorization = authorization end def to_headers headers = {} headers.merge!(@authorization.to_headers) if authorization headers end end class UpdateConnectionRequestOptions # Optional authorization object. # Pass in an active Stytch Member session token or session JWT and the request # will be run using that member's permissions. attr_accessor :authorization def initialize( authorization: nil ) @authorization = authorization end def to_headers headers = {} headers.merge!(@authorization.to_headers) if authorization headers end end class UpdateByURLRequestOptions # Optional authorization object. # Pass in an active Stytch Member session token or session JWT and the request # will be run using that member's permissions. attr_accessor :authorization def initialize( authorization: nil ) @authorization = authorization end def to_headers headers = {} headers.merge!(@authorization.to_headers) if authorization headers end end class DeleteVerificationCertificateRequestOptions # Optional authorization object. # Pass in an active Stytch Member session token or session JWT and the request # will be run using that member's permissions. attr_accessor :authorization def initialize( authorization: nil ) @authorization = authorization end def to_headers headers = {} headers.merge!(@authorization.to_headers) if authorization headers end end include Stytch::RequestHelper def initialize(connection) @connection = connection end # Create a new SAML Connection. # # == Parameters: # organization_id:: # 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. # The type of this field is +String+. # display_name:: # A human-readable display name for the connection. # The type of this field is nilable +String+. # identity_provider:: # Name of the IdP. Enum with possible values: `classlink`, `cyberark`, `duo`, `google-workspace`, `jumpcloud`, `keycloak`, `miniorange`, `microsoft-entra`, `okta`, `onelogin`, `pingfederate`, `rippling`, `salesforce`, `shibboleth`, or `generic`. # # Specifying a known provider allows Stytch to handle any provider-specific logic. # The type of this field is nilable +CreateConnectionRequestIdentityProvider+ (string enum). # # == Returns: # An object with the following fields: # request_id:: # 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. # The type of this field is +String+. # status_code:: # 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. # The type of this field is +Integer+. # connection:: # 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. # The type of this field is nilable +SAMLConnection+ (+object+). # # == Method Options: # This method supports an optional +StytchB2B::SSO::SAML::CreateConnectionRequestOptions+ object which will modify the headers sent in the HTTP request. def create_connection( organization_id:, display_name: nil, identity_provider: nil, method_options: nil ) headers = {} headers = headers.merge(method_options.to_headers) unless method_options.nil? request = {} request[:display_name] = display_name unless display_name.nil? request[:identity_provider] = identity_provider unless identity_provider.nil? post_request("/v1/b2b/sso/saml/#{organization_id}", request, headers) end # Updates an existing SAML connection. # # Note that a newly created connection will not become active until all of the following are provided: # * `idp_sso_url` # * `attribute_mapping` # * `idp_entity_id` # * `x509_certificate` # # == Parameters: # organization_id:: # 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. # The type of this field is +String+. # connection_id:: # Globally unique UUID that identifies a specific SSO `connection_id` for a Member. # The type of this field is +String+. # idp_entity_id:: # A globally unique name for the IdP. This will be provided by the IdP. # The type of this field is nilable +String+. # display_name:: # A human-readable display name for the connection. # The type of this field is nilable +String+. # attribute_mapping:: # An object that represents the attributes used to identify a Member. This object will map the IdP-defined User attributes to Stytch-specific values. Required attributes: `email` and one of `full_name` or `first_name` and `last_name`. # The type of this field is nilable +object+. # x509_certificate:: # A certificate that Stytch will use to verify the sign-in assertion sent by the IdP, in [PEM](https://en.wikipedia.org/wiki/Privacy-Enhanced_Mail) format. See our [X509 guide](https://stytch.com/docs/b2b/api/saml-certificates) for more info. # The type of this field is nilable +String+. # idp_sso_url:: # The URL for which assertions for login requests will be sent. This will be provided by the IdP. # The type of this field is nilable +String+. # saml_connection_implicit_role_assignments:: # 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. # The type of this field is nilable list of +SAMLConnectionImplicitRoleAssignment+. # saml_group_implicit_role_assignments:: # Defines the names of the SAML groups # that grant specific role assignments. For each group-Role pair, if a Member logs in with this SAML connection and # belongs to the specified SAML group, they will be granted the associated Role. See the # [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/role-assignment) for more information about role assignment. Before adding any group implicit role assignments, you must add a "groups" key to your SAML connection's # `attribute_mapping`. Make sure that your IdP is configured to correctly send the group information. # The type of this field is nilable list of +SAMLGroupImplicitRoleAssignment+. # alternative_audience_uri:: # 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. # The type of this field is nilable +String+. # identity_provider:: # Name of the IdP. Enum with possible values: `classlink`, `cyberark`, `duo`, `google-workspace`, `jumpcloud`, `keycloak`, `miniorange`, `microsoft-entra`, `okta`, `onelogin`, `pingfederate`, `rippling`, `salesforce`, `shibboleth`, or `generic`. # # Specifying a known provider allows Stytch to handle any provider-specific logic. # The type of this field is nilable +UpdateConnectionRequestIdentityProvider+ (string enum). # # == Returns: # An object with the following fields: # request_id:: # 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. # The type of this field is +String+. # status_code:: # 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. # The type of this field is +Integer+. # connection:: # 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. # The type of this field is nilable +SAMLConnection+ (+object+). # # == Method Options: # This method supports an optional +StytchB2B::SSO::SAML::UpdateConnectionRequestOptions+ object which will modify the headers sent in the HTTP request. def update_connection( organization_id:, connection_id:, idp_entity_id: nil, display_name: nil, attribute_mapping: nil, x509_certificate: nil, idp_sso_url: nil, saml_connection_implicit_role_assignments: nil, saml_group_implicit_role_assignments: nil, alternative_audience_uri: nil, identity_provider: nil, method_options: nil ) headers = {} headers = headers.merge(method_options.to_headers) unless method_options.nil? request = {} request[:idp_entity_id] = idp_entity_id unless idp_entity_id.nil? request[:display_name] = display_name unless display_name.nil? request[:attribute_mapping] = attribute_mapping unless attribute_mapping.nil? request[:x509_certificate] = x509_certificate unless x509_certificate.nil? request[:idp_sso_url] = idp_sso_url unless idp_sso_url.nil? request[:saml_connection_implicit_role_assignments] = saml_connection_implicit_role_assignments unless saml_connection_implicit_role_assignments.nil? request[:saml_group_implicit_role_assignments] = saml_group_implicit_role_assignments unless saml_group_implicit_role_assignments.nil? request[:alternative_audience_uri] = alternative_audience_uri unless alternative_audience_uri.nil? request[:identity_provider] = identity_provider unless identity_provider.nil? put_request("/v1/b2b/sso/saml/#{organization_id}/connections/#{connection_id}", request, headers) end # Used to update an existing SAML connection using an IDP metadata URL. # # A newly created connection will not become active until all the following are provided: # * `idp_sso_url` # * `idp_entity_id` # * `x509_certificate` # * `attribute_mapping` (must be supplied using [Update SAML Connection](update-saml-connection)) # # == Parameters: # organization_id:: # 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. # The type of this field is +String+. # connection_id:: # Globally unique UUID that identifies a specific SSO `connection_id` for a Member. # The type of this field is +String+. # metadata_url:: # A URL that points to the IdP metadata. This will be provided by the IdP. # The type of this field is +String+. # # == Returns: # An object with the following fields: # request_id:: # 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. # The type of this field is +String+. # status_code:: # 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. # The type of this field is +Integer+. # connection:: # 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. # The type of this field is nilable +SAMLConnection+ (+object+). # # == Method Options: # This method supports an optional +StytchB2B::SSO::SAML::UpdateByURLRequestOptions+ object which will modify the headers sent in the HTTP request. def update_by_url( organization_id:, connection_id:, metadata_url:, method_options: nil ) headers = {} headers = headers.merge(method_options.to_headers) unless method_options.nil? request = { metadata_url: metadata_url } put_request("/v1/b2b/sso/saml/#{organization_id}/connections/#{connection_id}/url", request, headers) end # Delete a SAML verification certificate. # # You may need to do this when rotating certificates from your IdP, since Stytch allows a maximum of 5 certificates per connection. There must always be at least one certificate per active connection. # # == Parameters: # organization_id:: # The organization ID that the SAML connection belongs to. # The type of this field is +String+. # connection_id:: # The ID of the SAML connection. # The type of this field is +String+. # certificate_id:: # The ID of the certificate to be deleted. # The type of this field is +String+. # # == Returns: # An object with the following fields: # request_id:: # 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. # The type of this field is +String+. # certificate_id:: # The ID of the certificate that was deleted. # The type of this field is +String+. # status_code:: # 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. # The type of this field is +Integer+. # # == Method Options: # This method supports an optional +StytchB2B::SSO::SAML::DeleteVerificationCertificateRequestOptions+ object which will modify the headers sent in the HTTP request. def delete_verification_certificate( organization_id:, connection_id:, certificate_id:, method_options: nil ) headers = {} headers = headers.merge(method_options.to_headers) unless method_options.nil? delete_request("/v1/b2b/sso/saml/#{organization_id}/connections/#{connection_id}/verification_certificates/#{certificate_id}", headers) end end class External class CreateConnectionRequestOptions # Optional authorization object. # Pass in an active Stytch Member session token or session JWT and the request # will be run using that member's permissions. attr_accessor :authorization def initialize( authorization: nil ) @authorization = authorization end def to_headers headers = {} headers.merge!(@authorization.to_headers) if authorization headers end end class UpdateConnectionRequestOptions # Optional authorization object. # Pass in an active Stytch Member session token or session JWT and the request # will be run using that member's permissions. attr_accessor :authorization def initialize( authorization: nil ) @authorization = authorization end def to_headers headers = {} headers.merge!(@authorization.to_headers) if authorization headers end end include Stytch::RequestHelper def initialize(connection) @connection = connection end # Create a new External SSO Connection. # # == Parameters: # organization_id:: # 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. # The type of this field is +String+. # external_organization_id:: # Globally unique UUID that identifies a different Organization within your Project. # The type of this field is +String+. # external_connection_id:: # Globally unique UUID that identifies a specific SSO connection configured for a different Organization in your Project. # The type of this field is +String+. # display_name:: # A human-readable display name for the connection. # The type of this field is nilable +String+. # connection_implicit_role_assignments:: # (no documentation yet) # The type of this field is nilable list of +SAMLConnectionImplicitRoleAssignment+. # group_implicit_role_assignments:: # (no documentation yet) # The type of this field is nilable list of +SAMLGroupImplicitRoleAssignment+. # # == Returns: # An object with the following fields: # request_id:: # 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. # The type of this field is +String+. # status_code:: # 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. # The type of this field is +Integer+. # connection:: # 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. # The type of this field is nilable +Connection+ (+object+). # # == Method Options: # This method supports an optional +StytchB2B::SSO::External::CreateConnectionRequestOptions+ object which will modify the headers sent in the HTTP request. def create_connection( organization_id:, external_organization_id:, external_connection_id:, display_name: nil, connection_implicit_role_assignments: nil, group_implicit_role_assignments: nil, method_options: nil ) headers = {} headers = headers.merge(method_options.to_headers) unless method_options.nil? request = { external_organization_id: external_organization_id, external_connection_id: external_connection_id } request[:display_name] = display_name unless display_name.nil? request[:connection_implicit_role_assignments] = connection_implicit_role_assignments unless connection_implicit_role_assignments.nil? request[:group_implicit_role_assignments] = group_implicit_role_assignments unless group_implicit_role_assignments.nil? post_request("/v1/b2b/sso/external/#{organization_id}", request, headers) end # Updates an existing External SSO connection. # # == Parameters: # organization_id:: # 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. # The type of this field is +String+. # connection_id:: # Globally unique UUID that identifies a specific External SSO Connection. # The type of this field is +String+. # display_name:: # A human-readable display name for the connection. # The type of this field is nilable +String+. # external_connection_implicit_role_assignments:: # 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. # The type of this field is nilable list of +ConnectionImplicitRoleAssignment+. # external_group_implicit_role_assignments:: # Defines the names of the groups # that grant specific role assignments. For each group-Role pair, if a Member logs in with this external connection and # belongs to the specified group, they will be granted the associated Role. See the # [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/role-assignment) for more information about role assignment. Before adding any group implicit role assignments to an external connection, you must add a "groups" key to the underlying SAML connection's # `attribute_mapping`. Make sure that the SAML connection IdP is configured to correctly send the group information. Implicit role assignments are not supported # for External connections if the underlying SSO connection is an OIDC connection. # The type of this field is nilable list of +GroupImplicitRoleAssignment+. # # == Returns: # An object with the following fields: # request_id:: # 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. # The type of this field is +String+. # status_code:: # 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. # The type of this field is +Integer+. # connection:: # 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. # The type of this field is nilable +Connection+ (+object+). # # == Method Options: # This method supports an optional +StytchB2B::SSO::External::UpdateConnectionRequestOptions+ object which will modify the headers sent in the HTTP request. def update_connection( organization_id:, connection_id:, display_name: nil, external_connection_implicit_role_assignments: nil, external_group_implicit_role_assignments: nil, method_options: nil ) headers = {} headers = headers.merge(method_options.to_headers) unless method_options.nil? request = {} request[:display_name] = display_name unless display_name.nil? request[:external_connection_implicit_role_assignments] = external_connection_implicit_role_assignments unless external_connection_implicit_role_assignments.nil? request[:external_group_implicit_role_assignments] = external_group_implicit_role_assignments unless external_group_implicit_role_assignments.nil? put_request("/v1/b2b/sso/external/#{organization_id}/connections/#{connection_id}", request, headers) end end end end