Skip to content

SSO module

Reference to the cloud.sso.py module.

sso

Single Sign-On (SSO) functionality for the Nextmv Cloud API.

This module provides classes and methods to manage Single Sign-On (SSO) configurations for Nextmv Cloud organizations (accounts).

CLASS DESCRIPTION
SSOConfiguration

Represents the SSO configuration for a Nextmv Cloud organization (account) and provides methods to create, retrieve, update, enable, disable, and delete SSO configurations.

SSOConfiguration

Bases: BaseModel

Configuration for Single Sign-On (SSO) in Nextmv Cloud.

You can import the SSOConfiguration class directly from cloud:

from nextmv.cloud import SSOConfiguration
ATTRIBUTE DESCRIPTION
allow_non_domain_users

Whether to allow users who are not part of the SSO domain to access the Nextmv Cloud organization (account). Default is False.

TYPE: (bool, optional)

enabled

Whether SSO is enabled for the Nextmv Cloud organization (account).

TYPE: (bool, optional)

metadata_url

The URL to the SSO metadata document.

TYPE: (str, optional)

metadata_document

The SSO metadata document as a string.

TYPE: (str, optional)

mapped_domains

A list of mapped domains in the SSO configuration. This is read only, mapped domains are added through an explicit command.

TYPE: (list[str], optional)

client

Client to use for interacting with the Nextmv Cloud API. This is an SDK-specific attribute and it is not part of the API representation of an SSO configuration.

TYPE: Client

sso_endpoint

Base endpoint for SSO operations. This is an SDK-specific attribute and it is not part of the API representation of an SSO configuration.

TYPE: str

allow_non_domain_users class-attribute instance-attribute

allow_non_domain_users: bool = False

Whether to allow users who are not part of the SSO domain to access the Nextmv Cloud organization (account).

enabled class-attribute instance-attribute

enabled: bool | None = None

Whether SSO is enabled for the Nextmv Cloud organization (account).

metadata_url class-attribute instance-attribute

metadata_url: str | None = None

The URL to the SSO metadata document.

metadata_document class-attribute instance-attribute

metadata_document: str | None = None

The SSO metadata document as a string.

mapped_domains class-attribute instance-attribute

mapped_domains: list[str] | None = None

A list of mapped domains in the SSO configuration. Mapped domains redirect additional domains to your IDP for federated authentication.

client class-attribute instance-attribute

client: Client = Field(exclude=True)

Client to use for interacting with the Nextmv Cloud API.

sso_endpoint class-attribute instance-attribute

sso_endpoint: str = Field(
    exclude=True, default="v1/enterprise/sso"
)

get classmethod

get(client: Client) -> SSOConfiguration

Retrieve the SSO configuration for the current Nextmv Cloud organization (account).

PARAMETER DESCRIPTION
client

Client to use for interacting with the Nextmv Cloud API.

TYPE: Client

RETURNS DESCRIPTION
SSOConfiguration

The SSO configuration for the organization (account).

RAISES DESCRIPTION
HTTPError

If the response status code is not 2xx.

Source code in nextmv-py/nextmv/nextmv/cloud/sso.py
@classmethod
def get(cls, client: Client) -> "SSOConfiguration":
    """
    Retrieve the SSO configuration for the current Nextmv Cloud
    organization (account).

    Parameters
    ----------
    client : Client
        Client to use for interacting with the Nextmv Cloud API.

    Returns
    -------
    SSOConfiguration
        The SSO configuration for the organization (account).

    Raises
    ------
    requests.HTTPError
        If the response status code is not 2xx.
    """

    response = client.request(
        method="GET",
        endpoint="v1/enterprise/sso",
    )
    return cls.from_dict({"client": client} | response.json())

new classmethod

new(
    client: Client,
    allow_non_domain_users: bool = False,
    enabled: bool | None = None,
    metadata_url: str | None = None,
    metadata_document: str | None = None,
) -> None

Create a new SSO configuration for the current Nextmv Cloud organization (account).

This method does not return the created configuration. To retrieve the configuration after creation, use the get method.

PARAMETER DESCRIPTION
client

Client to use for interacting with the Nextmv Cloud API.

TYPE: Client

allow_non_domain_users

Whether to allow users who are not part of the SSO domain to access the Nextmv Cloud organization (account). Default is False.

TYPE: bool DEFAULT: False

enabled

Whether SSO is enabled for the Nextmv Cloud organization (account).

TYPE: bool DEFAULT: None

metadata_url

The URL to the SSO metadata document.

TYPE: str DEFAULT: None

metadata_document

The SSO metadata document as a string.

TYPE: str DEFAULT: None

RAISES DESCRIPTION
HTTPError

If the response status code is not 2xx.

Source code in nextmv-py/nextmv/nextmv/cloud/sso.py
@classmethod
def new(
    cls,
    client: Client,
    allow_non_domain_users: bool = False,
    enabled: bool | None = None,
    metadata_url: str | None = None,
    metadata_document: str | None = None,
) -> None:
    """
    Create a new SSO configuration for the current Nextmv Cloud
    organization (account).

    This method does not return the created configuration. To retrieve
    the configuration after creation, use the `get` method.

    Parameters
    ----------
    client : Client
        Client to use for interacting with the Nextmv Cloud API.
    allow_non_domain_users : bool, optional
        Whether to allow users who are not part of the SSO domain to access
        the Nextmv Cloud organization (account). Default is `False`.
    enabled : bool, optional
        Whether SSO is enabled for the Nextmv Cloud organization (account).
    metadata_url : str, optional
        The URL to the SSO metadata document.
    metadata_document : str, optional
        The SSO metadata document as a string.

    Raises
    ------
    requests.HTTPError
        If the response status code is not 2xx.
    """

    metadata_document = _resolve_metadata_document(metadata_document)

    payload = {
        "allow_non_domain_users": allow_non_domain_users,
        "enabled": enabled,
        "metadata_url": metadata_url,
        "metadata_document": metadata_document,
    }

    client.request(
        method="POST",
        endpoint="v1/enterprise/sso",
        payload=payload,
    )

delete

delete() -> None

Delete the SSO configuration for the current Nextmv Cloud organization (account).

RAISES DESCRIPTION
HTTPError

If the response status code is not 2xx.

Source code in nextmv-py/nextmv/nextmv/cloud/sso.py
def delete(self) -> None:
    """
    Delete the SSO configuration for the current Nextmv Cloud
    organization (account).

    Raises
    ------
    requests.HTTPError
        If the response status code is not 2xx.
    """

    self.client.request(
        method="DELETE",
        endpoint=self.sso_endpoint,
    )

delete_domain

delete_domain(domain: str) -> None

Deletes a domain from an existing SSO configuration for the current Nextmv Cloud organization (account).

RAISES DESCRIPTION
HTTPError

If the response status code is not 2xx.

Source code in nextmv-py/nextmv/nextmv/cloud/sso.py
def delete_domain(self, domain: str) -> None:
    """
    Deletes a domain from an existing SSO configuration for the current Nextmv
    Cloud organization (account).

    Raises
    ------
    requests.HTTPError
        If the response status code is not 2xx.
    """

    self.client.request(
        method="DELETE",
        endpoint=f"{self.sso_endpoint}/domains/{domain}",
    )

disable

disable() -> None

Disable SSO for the current Nextmv Cloud organization (account).

RAISES DESCRIPTION
HTTPError

If the response status code is not 2xx.

Source code in nextmv-py/nextmv/nextmv/cloud/sso.py
def disable(self) -> None:
    """
    Disable SSO for the current Nextmv Cloud organization (account).

    Raises
    ------
    requests.HTTPError
        If the response status code is not 2xx.
    """

    self.client.request(
        method="PUT",
        endpoint=f"{self.sso_endpoint}/disable",
    )

enable

enable() -> None

Enable SSO for the current Nextmv Cloud organization (account).

RAISES DESCRIPTION
HTTPError

If the response status code is not 2xx.

Source code in nextmv-py/nextmv/nextmv/cloud/sso.py
def enable(self) -> None:
    """
    Enable SSO for the current Nextmv Cloud organization (account).

    Raises
    ------
    requests.HTTPError
        If the response status code is not 2xx.
    """

    self.client.request(
        method="PUT",
        endpoint=f"{self.sso_endpoint}/enable",
    )

update

update(
    metadata_url: str | None = None,
    metadata_document: str | None = None,
) -> None

Update the SSO configuration for the current Nextmv Cloud organization (account).

This method does not return the updated configuration. To retrieve the configuration after updating, use the get method. If you wish to enable or disable SSO, please use the enable and disable methods instead.

PARAMETER DESCRIPTION
metadata_url

The URL to the SSO metadata document.

TYPE: str DEFAULT: None

metadata_document

The SSO metadata document as a string.

TYPE: str DEFAULT: None

RAISES DESCRIPTION
HTTPError

If the response status code is not 2xx.

Source code in nextmv-py/nextmv/nextmv/cloud/sso.py
def update(
    self,
    metadata_url: str | None = None,
    metadata_document: str | None = None,
) -> None:
    """
    Update the SSO configuration for the current Nextmv Cloud
    organization (account).

    This method does not return the updated configuration. To retrieve the
    configuration after updating, use the `get` method. If you wish to
    enable or disable SSO, please use the `enable` and `disable` methods
    instead.

    Parameters
    ----------
    metadata_url : str, optional
        The URL to the SSO metadata document.
    metadata_document : str, optional
        The SSO metadata document as a string.

    Raises
    ------
    requests.HTTPError
        If the response status code is not 2xx.
    """

    config = self.get(self.client)
    config_dict = config.to_dict()
    payload = config_dict.copy()

    if metadata_url is not None and metadata_url != "":
        payload["metadata_url"] = metadata_url
    if metadata_document is not None and metadata_document != "":
        metadata_document = _resolve_metadata_document(metadata_document)
        payload["metadata_document"] = metadata_document

    self.client.request(
        method="PUT",
        endpoint=self.sso_endpoint,
        payload=payload,
    )