Zoom_IAM

An Identity and Access Management integration template.

Identity and Access Management · Zoom

Details

IDZoom_IAM
ProviderZoom
CategoryIdentity and Access Management
From Version6.0.0
Docker Imagedemisto/auth-utils:1.0.0.5476008
Supported ModulesAgentix XSIAM EDR Cortex Cloud Cloud Runtime Security

README

An Identity and Access Management integration template.
This integration was integrated and tested with version 2.0.0 of Zoom_IAM.

Configure Zoom_IAM in Cortex

Parameter Description Required
Server URL (e.g., ‘https://api.zoom.us/v2/’)   False
Account ID (OAuth)   False
Client ID (OAuth)   False
Client Secret (OAuth)   False
API Key (JWT-Deprecated) This authentication method is deprecated. False
API Secret (JWT-Deprecated) This authentication method is deprecated. False
Use system proxy settings   False
Trust any certificate (not secure)   False
Allow disabling users   False
Allow enabling users   False
Incoming Mapper   False
Outgoing Mapper Cortex XSOAR only parameter. False

Commands

You can execute these commands from the CLI, as part of an automation, or in a playbook.
After you successfully execute a command, a DBot message appears in the War Room with the command details.

iam-disable-user


Disable an active user.

Base Command

iam-disable-user

Input

Argument Name Description Required
user-profile A User Profile indicator.
For example: {"email": "john.doe@example.com"}
.
Required

Context Output

Path Type Description
IAM.Vendor.active Boolean When true, indicates that the employee’s status is active in the 3rd-party integration.
IAM.Vendor.brand String Name of the integration.
IAM.Vendor.details string Provides the raw data from the 3rd-party integration.
IAM.Vendor.email String The employee’s email address.
IAM.Vendor.errorCode Number HTTP error response code.
IAM.Vendor.errorMessage String Reason why the API failed.
IAM.Vendor.id String The employee’s user ID in the app.
IAM.Vendor.instanceName string Name of the integration instance.
IAM.Vendor.success Boolean When true, indicates that the command was executed successfully.
IAM.Vendor.username String The employee’s username in the app.

Command example

!iam-disable-user user-profile=`{"email": "example@example.com", "givenname": "Example"}`

Context Example

{
    "IAM": {
        "UserProfile": {
            "email": "example@example.com",
            "givenname": "Example"
        },
        "Vendor": [
            {
                "action": "disable",
                "active": false,
                "brand": "Zoom_IAM",
                "details": {
                    "email": "example@example.com",
                    "givenname": "Example"
                },
                "email": "example@example.com",
                "errorCode": null,
                "errorMessage": "",
                "id": "6mIygOyeTT61Wzw_PAo5jw",
                "instanceName": "Zoom_IAM_instance_1 JWT",
                "reason": "",
                "skipped": false,
                "success": true,
                "username": ""
            },
            {
                "action": "disable",
                "active": null,
                "brand": "Zoom_IAM",
                "details": {
                    "account_id": "aeKD2BFJRASt1QVURWo9CA",
                    "account_number": 1114287,
                    "cluster": "us06",
                    "cms_user_id": "",
                    "created_at": "2020-06-16T06:57:23Z",
                    "dept": "",
                    "email": "example@example.com",
                    "first_name": "Example",
                    "group_ids": [],
                    "id": "6mIygOyeTT61Wzw_PAo5jw",
                    "im_group_ids": [],
                    "jid": "6miygoyett61wzw_pao5jw@xmpp.zoom.us",
                    "job_title": "",
                    "language": "en-US",
                    "last_client_version": "5.8.7.2058(win)",
                    "last_login_time": "2022-08-24T07:25:49Z",
                    "last_name": "Example",
                    "location": "",
                    "login_types": [
                        1
                    ],
                    "personal_meeting_url": "https://us06web.zoom.us/j/3269259758?pwd=Q2VTN1JsM2J2OCtmS1hWaHBTUmV6QT09",
                    "phone_country": "",
                    "phone_number": "",
                    "pic_url": "https://lh3.googleusercontent.com/a/AItbvmn0GJLCTIkOIatpkUy-PuEf-tFQEnBVOUxcT2oB=s96-c",
                    "pmi": 3269259758,
                    "role_id": "2",
                    "role_name": "Member",
                    "status": "inactive",
                    "timezone": "Asia/Jerusalem",
                    "type": 1,
                    "use_pmi": false,
                    "user_created_at": "2020-06-16T06:57:23Z",
                    "verified": 0
                },
                "email": "example@example.com",
                "errorCode": null,
                "errorMessage": "",
                "id": null,
                "instanceName": "Zoom_IAM_instance_2 OAuth",
                "reason": "User is already disabled.",
                "skipped": true,
                "success": true,
                "username": null
            }
        ]
    }
}

Human Readable Output

Disable User Results (Zoom_IAM)

brand instanceName success active id email details
Zoom_IAM Zoom_IAM_instance_1 JWT true false 6mIygOyeTT61Wzw_PAo5jw example@example.com email: example@example.com
givenname: Example

iam-enable-user


Enable a deactivated user.

Base Command

iam-enable-user

Input

Argument Name Description Required
user-profile A User Profile indicator. Required

Context Output

Path Type Description
IAM.Vendor.active Boolean When true, indicates that the employee’s status is active in the 3rd-party integration.
IAM.Vendor.brand String Name of the integration.
IAM.Vendor.details string Provides the raw data from the 3rd-party integration.
IAM.Vendor.email String The employee’s email address.
IAM.Vendor.errorCode Number HTTP error response code.
IAM.Vendor.errorMessage String Reason why the API failed.
IAM.Vendor.id String The employee’s user ID in the app.
IAM.Vendor.instanceName string Name of the integration instance.
IAM.Vendor.success Boolean When true, indicates that the command was executed successfully.
IAM.Vendor.username String The employee’s username in the app.

Command example

!iam-enable-user user-profile=`{"email": "example@example.com", "givenname": "Example"}`

Context Example

{
    "IAM": {
        "UserProfile": {
            "email": "example@example.com",
            "givenname": "Example"
        },
        "Vendor": [
            {
                "action": "enable",
                "active": true,
                "brand": "Zoom_IAM",
                "details": {
                    "email": "example@example.com",
                    "givenname": "Example"
                },
                "email": "example@example.com",
                "errorCode": null,
                "errorMessage": "",
                "id": "6mIygOyeTT61Wzw_PAo5jw",
                "instanceName": "Zoom_IAM_instance_2 OAuth",
                "reason": "",
                "skipped": false,
                "success": true,
                "username": ""
            },
            {
                "action": "enable",
                "active": true,
                "brand": "Zoom_IAM",
                "details": {
                    "email": "example@example.com",
                    "givenname": "Example"
                },
                "email": "example@example.com",
                "errorCode": null,
                "errorMessage": "",
                "id": "6mIygOyeTT61Wzw_PAo5jw",
                "instanceName": "Zoom_IAM_instance_1 JWT",
                "reason": "",
                "skipped": false,
                "success": true,
                "username": ""
            }
        ]
    }
}

Human Readable Output

Enable User Results (Zoom_IAM)

brand instanceName success active id email details
Zoom_IAM Zoom_IAM_instance_2 OAuth true true 6mIygOyeTT61Wzw_PAo5jw example@example.com email: example@example.com
givenname: Example

iam-get-user


Retrieves a single user resource.

Base Command

iam-get-user

Input

Argument Name Description Required
user-profile A User Profile indicator. Required

Context Output

There is no context output for this command.

Command example

!iam-get-user user-profile=`{"email": "example@example.com", "givenname": "Example"}`

Context Example

{
    "IAM": {
        "UserProfile": {
            "account_id": "aeKD2BFJRASt1QVURWo9CA",
            "account_number": 1114287,
            "cluster": "us06",
            "cms_user_id": "",
            "created_at": "2020-06-16T06:57:23Z",
            "dept": "",
            "email": "example@example.com",
            "first_name": "Example",
            "group_ids": [],
            "id": "6mIygOyeTT61Wzw_PAo5jw",
            "im_group_ids": [],
            "jid": "6miygoyett61wzw_pao5jw@xmpp.zoom.us",
            "job_title": "",
            "language": "en-US",
            "last_client_version": "5.8.7.2058(win)",
            "last_login_time": "2022-08-24T07:25:49Z",
            "last_name": "Example",
            "location": "",
            "login_types": [
                1
            ],
            "personal_meeting_url": "https://us06web.zoom.us/j/3269259758?pwd=Q2VTN1JsM2J2OCtmS1hWaHBTUmV6QT09",
            "phone_country": "",
            "phone_number": "",
            "pic_url": "https://lh3.googleusercontent.com/a/AItbvmn0GJLCTIkOIatpkUy-PuEf-tFQEnBVOUxcT2oB=s96-c",
            "pmi": 3269259758,
            "role_id": "2",
            "role_name": "Member",
            "status": "active",
            "timezone": "Asia/Jerusalem",
            "type": 1,
            "use_pmi": false,
            "user_created_at": "2020-06-16T06:57:23Z",
            "verified": 0
        },
        "Vendor": [
            {
                "action": "get",
                "active": true,
                "brand": "Zoom_IAM",
                "details": {
                    "account_id": "aeKD2BFJRASt1QVURWo9CA",
                    "account_number": 1114287,
                    "cluster": "us06",
                    "cms_user_id": "",
                    "created_at": "2020-06-16T06:57:23Z",
                    "dept": "",
                    "email": "example@example.com",
                    "first_name": "Example",
                    "group_ids": [],
                    "id": "6mIygOyeTT61Wzw_PAo5jw",
                    "im_group_ids": [],
                    "jid": "6miygoyett61wzw_pao5jw@xmpp.zoom.us",
                    "job_title": "",
                    "language": "en-US",
                    "last_client_version": "5.8.7.2058(win)",
                    "last_login_time": "2022-08-24T07:25:49Z",
                    "last_name": "Example",
                    "location": "",
                    "login_types": [
                        1
                    ],
                    "personal_meeting_url": "https://us06web.zoom.us/j/3269259758?pwd=Q2VTN1JsM2J2OCtmS1hWaHBTUmV6QT09",
                    "phone_country": "",
                    "phone_number": "",
                    "pic_url": "https://lh3.googleusercontent.com/a/AItbvmn0GJLCTIkOIatpkUy-PuEf-tFQEnBVOUxcT2oB=s96-c",
                    "pmi": 3269259758,
                    "role_id": "2",
                    "role_name": "Member",
                    "status": "active",
                    "timezone": "Asia/Jerusalem",
                    "type": 1,
                    "use_pmi": false,
                    "user_created_at": "2020-06-16T06:57:23Z",
                    "verified": 0
                },
                "email": "example@example.com",
                "errorCode": null,
                "errorMessage": "",
                "id": "6mIygOyeTT61Wzw_PAo5jw",
                "instanceName": "Zoom_IAM_instance_2 OAuth",
                "reason": "",
                "skipped": false,
                "success": true,
                "username": ""
            },
            {
                "action": "get",
                "active": true,
                "brand": "Zoom_IAM",
                "details": {
                    "account_id": "aeKD2BFJRASt1QVURWo9CA",
                    "account_number": 1114287,
                    "cluster": "us06",
                    "cms_user_id": "",
                    "created_at": "2020-06-16T06:57:23Z",
                    "dept": "",
                    "email": "example@example.com",
                    "first_name": "Example",
                    "group_ids": [],
                    "id": "6mIygOyeTT61Wzw_PAo5jw",
                    "im_group_ids": [],
                    "jid": "6miygoyett61wzw_pao5jw@xmpp.zoom.us",
                    "job_title": "",
                    "language": "en-US",
                    "last_client_version": "5.8.7.2058(win)",
                    "last_login_time": "2022-08-24T07:25:49Z",
                    "last_name": "Example",
                    "location": "",
                    "login_types": [
                        1
                    ],
                    "personal_meeting_url": "https://us06web.zoom.us/j/3269259758?pwd=Q2VTN1JsM2J2OCtmS1hWaHBTUmV6QT09",
                    "phone_country": "",
                    "phone_number": "",
                    "pic_url": "https://lh3.googleusercontent.com/a/AItbvmn0GJLCTIkOIatpkUy-PuEf-tFQEnBVOUxcT2oB=s96-c",
                    "pmi": 3269259758,
                    "role_id": "2",
                    "role_name": "Member",
                    "status": "active",
                    "timezone": "Asia/Jerusalem",
                    "type": 1,
                    "use_pmi": false,
                    "user_created_at": "2020-06-16T06:57:23Z",
                    "verified": 0
                },
                "email": "example@example.com",
                "errorCode": null,
                "errorMessage": "",
                "id": "6mIygOyeTT61Wzw_PAo5jw",
                "instanceName": "Zoom_IAM_instance_1 JWT",
                "reason": "",
                "skipped": false,
                "success": true,
                "username": ""
            }
        ]
    }
}

Human Readable Output

Get User Results (Zoom_IAM)

brand instanceName success active id email details
Zoom_IAM Zoom_IAM_instance_1 JWT true true 6mIygOyeTT61Wzw_PAo5jw example@example.com id: 6mIygOyeTT61Wzw_PAo5jw
first_name: Example
last_name: Example
email: example@example.com
type: 1
role_name: Member
pmi: 3269259758
use_pmi: false
personal_meeting_url: https://us06web.zoom.us/j/3269259758?pwd=Q2VTN1JsM2J2OCtmS1hWaHBTUmV6QT09
timezone: Asia/Jerusalem
verified: 0
dept:
created_at: 2020-06-16T06:57:23Z
last_login_time: 2022-08-24T07:25:49Z
last_client_version: 5.8.7.2058(win)
pic_url: https://lh3.googleusercontent.com/a/AItbvmn0GJLCTIkOIatpkUy-PuEf-tFQEnBVOUxcT2oB=s96-c
cms_user_id:
jid: 6miygoyett61wzw_pao5jw@xmpp.zoom.us
group_ids:
im_group_ids:
account_id: aeKD2BFJRASt1QVURWo9CA
language: en-US
phone_country:
phone_number:
status: active
job_title:
location:
login_types: 1
role_id: 2
account_number: 1114287
cluster: us06
user_created_at: 2020-06-16T06:57:23Z

get-mapping-fields


Retrieves a User Profile schema, which holds all of the user fields within the application. Used for outgoing-mapping through the Get Schema option.

Base Command

get-mapping-fields

Input

There are no input arguments for this command.

Context Output

There is no context output for this command.

Incident Mirroring

You can enable incident mirroring between Cortex XSOAR incidents and Zoom_IAM corresponding events (available from Cortex XSOAR version 6.0.0).
To set up the mirroring:
Enable Fetching incidents in your instance configuration.

Newly fetched incidents will be mirrored in the chosen direction. However, this selection does not affect existing incidents.
Important Note: To ensure the mirroring works as expected, mappers are required, both for incoming and outgoing, to map the expected fields in Cortex XSOAR and Zoom_IAM.

Configuration parameters

  • url — Server URL (e.g., 'https://api.zoom.us/v2/')
  • account_id — Account ID (OAuth)
  • credentials — Client ID (OAuth)
  • creds_api_key
  • creds_api_secret
  • api_key — API Key (JWT-Deprecated)
  • api_secret — API Secret (JWT-Deprecated)
  • proxy — Use system proxy settings
  • insecure — Trust any certificate (not secure)
  • disable-user-enabled — Allow disabling users
  • enable-user-enabled — Allow enabling users
  • mapper_in — Incoming Mapper
  • mapper_out — Outgoing Mapper

Commands (4)

  • get-mapping-fields

    Retrieves a User Profile schema, which holds all of the user fields within the application. Used for outgoing-mapping through the Get Schema option.

  • iam-disable-user

    Disable an active user.

  • iam-enable-user

    Enable a deactivated user.

  • iam-get-user

    Retrieves a single user resource.

import demistomock as demisto  # noqa: F401
import urllib3
from CommonServerPython import *  # noqa: F401
from IAMApiModule import *  # noqa: E402
from ZoomApiModule import *  # noqa: E402

# Disable insecure warnings
urllib3.disable_warnings()

DEFAULT_OUTGOING_MAPPER = "User Profile - SCIM (Outgoing)"
DEFAULT_INCOMING_MAPPER = "User Profile - SCIM (Incoming)"

ERROR_CODES_TO_SKIP = [404]

"""CLIENT CLASS"""


class Client(Zoom_Client):
    """A client class that implements logic to authenticate with Zoom application."""

    def test(self):
        """Tests connectivity with the application."""

        self.get_user("", "me")
        return "ok"

    def get_user(self, _, filter_value: str) -> Optional[IAMUserAppData]:
        uri = f"/users/{filter_value}"

        res = self.error_handled_http_request(
            method="GET",
            url_suffix=uri,
            headers={
                "authorization": f"Bearer {self.access_token}",
                "Accept": "application/json",
                "Content-Type": "application/json",
            },
        )
        if res and (not res.get("users")):
            user_app_data = res
            user_id = user_app_data.get("id")
            is_active = user_app_data.get("status") == "active"
            email = user_app_data.get("email")
            # the API does not provide user name
            username = ""

            return IAMUserAppData(user_id, username, is_active, user_app_data, email=email)
        return None

    def update_user(self, user_id: str, user_data: Dict[str, Any]) -> IAMUserAppData:
        """Updates a user in the application using REST API.

        :type user_id: ``str``
        :param user_id: ID of the user in the application

        :type user_data: ``Dict[str, Any]``
        :param user_data: User data in the application format

        :return: An IAMUserAppData object that contains the data of the updated user in the application.
        :rtype: ``IAMUserAppData``
        """
        uri = f"/users/{user_id}/status"
        self.error_handled_http_request(
            method="PUT",
            url_suffix=uri,
            json_data=user_data,
            return_empty_response=True,
            headers={
                "authorization": f"Bearer {self.access_token}",
                "Accept": "application/json",
                "Content-Type": "application/json",
            },
        )
        # res is an empty *response object*
        user_app_data: dict = {}
        # if we wanted to disable the user and request succeeded,
        # we get to this line and know the user's status
        is_active = user_data.get("action", "") == "activate"
        username = ""

        return IAMUserAppData(user_id, username, is_active, user_app_data)

    def disable_user(self, user_id: str) -> IAMUserAppData:
        """Disables a user in the application using REST API.

        :type user_id: ``str``
        :param user_id: ID of the user in the application

        :return: An IAMUserAppData object that contains the data of the user in the application.
        :rtype: ``IAMUserAppData``
        """

        user_data = {"action": "deactivate"}
        return self.update_user(user_id, user_data)

    def enable_user(self, user_id: str) -> IAMUserAppData:
        """Enables a user in the application using REST API.

        :type user_id: ``str``
        :param user_id: ID of the user in the application

        :return: An IAMUserAppData object that contains the data of the user in the application.
        :rtype: ``IAMUserAppData``
        """

        user_data = {"action": "activate"}
        return self.update_user(user_id, user_data)

    def get_app_fields(self):
        user_app_data = self.get_user("", "me")
        if user_app_data:
            return {k: underscoreToCamelCase(k) for k, _ in user_app_data.full_data.items()}
        raise DemistoException("Could not retrieve fields for mapping")

    @staticmethod
    def handle_exception(user_profile: IAMUserProfile, e: Union[DemistoException, Exception], action: IAMActions):
        """Handles failed responses from the application API by setting the User Profile object with the result.
            The result entity should contain the following data:
            1. action        (``IAMActions``)       The failed action                       Required
            2. success       (``bool``)             The success status                      Optional (by default, True)
            3. skip          (``bool``)             Whether or not the command was skipped  Optional (by default, False)
            3. skip_reason   (``str``)              Skip reason                             Optional (by default, None)
            4. error_code    (``Union[str, int]``)  HTTP error code                         Optional (by default, None)
            5. error_message (``str``)              The error description                   Optional (by default, None)

            Note: This is the place to determine how to handle specific edge cases from the API, e.g.,
            when a DISABLE action was made on a user which is already disabled and therefore we can't
            perform another DISABLE action.

        :type user_profile: ``IAMUserProfile``
        :param user_profile: The user profile object

        :type e: ``Union[DemistoException, Exception]``
        :param e: The exception object - if type is DemistoException, holds the response json object (`res` attribute)

        :type action: ``IAMActions``
        :param action: An enum represents the current action (GET, UPDATE, CREATE, DISABLE or ENABLE)
        """
        if isinstance(e, DemistoException) and e.res is not None:
            error_code = e.res.status_code

            if action == IAMActions.DISABLE_USER and error_code in ERROR_CODES_TO_SKIP:
                skip_message = "Users is already disabled or does not exist in the system."
                user_profile.set_result(action=action, skip=True, skip_reason=skip_message)

            try:
                resp = e.res.json()
                error_message = get_error_details(resp)
            except ValueError:
                error_message = str(e)
        else:
            error_code = ""
            error_message = str(e)

        user_profile.set_result(action=action, success=False, error_code=error_code, error_message=error_message)

        demisto.error(traceback.format_exc())


"""HELPER FUNCTIONS"""


def get_error_details(res: Dict[str, Any]) -> str:
    """Parses the error details retrieved from the application and outputs the resulted string.

    :type res: ``Dict[str, Any]``
    :param res: The error data retrieved from the application.

    :return: The parsed error details.
    :rtype: ``str``
    """
    message = res.get("code", "")
    details = res.get("message", "")
    return f"{message}: {details}"


"""COMMAND FUNCTIONS"""


def test_module(client: Client):
    """Tests connectivity with the client.
    Takes as an argument all client arguments to create a new client
    """
    try:
        client.test()
    except DemistoException as e:
        error_message = e.message
        if "Invalid access token" in error_message:
            error_message = INVALID_CREDENTIALS
        elif "The Token's Signature resulted invalid" in error_message:
            error_message = INVALID_API_SECRET
        elif "Invalid client_id or client_secret" in error_message:
            error_message = INVALID_ID_OR_SECRET
        else:
            error_message = f"Problem reaching Zoom API, check your credentials. Error message: {error_message}"
        return error_message
    return "ok"


def get_mapping_fields(client: Client):
    mapping = client.get_app_fields()
    incident_type_scheme = SchemeTypeMapping(type_name=IAMUserProfile.DEFAULT_INCIDENT_TYPE, fields=mapping)
    return GetMappingFieldsResponse([incident_type_scheme])


def check_authentication_type_arguments(api_key: str, api_secret: str, account_id: str, client_id: str, client_secret: str):
    if any((api_key, api_secret)) and any((account_id, client_id, client_secret)):
        raise DemistoException("""Too many fields were filled.
                                   You should fill the Account ID, Client ID, and Client Secret fields (OAuth),
                                   OR the API Key and API Secret fields (JWT - Deprecated)""")


def main():  # pragma: no cover
    user_profile = None
    params = demisto.params()
    base_url = params.get("url")
    api_key = params.get("creds_api_key", {}).get("password") or params.get("api_key")
    api_secret = params.get("creds_api_secret", {}).get("password") or params.get("api_secret")
    account_id = params.get("account_id")
    client_id = params.get("credentials", {}).get("identifier")
    client_secret = params.get("credentials", {}).get("password")
    mapper_in = params.get("mapper_in", DEFAULT_INCOMING_MAPPER)
    verify_certificate = not params.get("insecure", False)
    proxy = params.get("proxy", False)
    command = demisto.command()
    args = demisto.args()

    is_disable_enabled = argToBoolean(params.get("disable-user-enabled"))
    is_enable_enabled = argToBoolean(params.get("enable-user-enabled"))

    iam_command = IAMCommand(
        is_create_enabled=False,
        is_enable_enabled=is_enable_enabled,
        is_disable_enabled=is_disable_enabled,
        is_update_enabled=False,
        create_if_not_exists=False,
        mapper_in=mapper_in,
        # Currently we don't use scim API endpoints, so we don't map the arguments.
        mapper_out=None,
        get_user_iam_attrs=["id", "username", "email"],
    )
    try:
        check_authentication_type_arguments(api_key, api_secret, account_id, client_id, client_secret)

        client = Client(
            base_url=base_url,
            verify=verify_certificate,
            proxy=proxy,
            api_key=api_key,
            api_secret=api_secret,
            account_id=account_id,
            client_id=client_id,
            client_secret=client_secret,
        )

        if command == "test-module":
            return_results(test_module(client=client))

        demisto.debug(f"Command being called is {command}")

        """CRUD commands"""
        if command == "iam-disable-user":
            user_profile = iam_command.disable_user(client, args)
        if command == "iam-enable-user":
            user_profile = iam_command.enable_user(client, args)
        if command == "iam-get-user":
            user_profile = iam_command.get_user(client, args)

        if user_profile:
            return_results(user_profile)

        """non-CRUD commands"""

        if command == "get-mapping-fields":
            return_results(get_mapping_fields(client))

    except Exception as e:
        # For any other integration command exception, return an error
        return_error(f"Failed to execute {command} command. Error: {e!s}")


if __name__ in ("__main__", "__builtin__", "builtins"):
    main()