From 16fe51ee9938b3de134bae791977d7f3c0a910c7 Mon Sep 17 00:00:00 2001 From: Guillaume BOURGEOIS Date: Sun, 12 Jul 2026 15:39:19 +0200 Subject: [PATCH] feat(sailpoint): new SailPoint IdentityNow IGA integration IdentityNow API v3, 6 commands: list/get identities, list accounts, disable/ enable account (containment). OAuth2 client-credentials auth, stdlib-only. Co-Authored-By: Claude Opus 4.8 (1M context) --- integrations/sailpoint/manifest.yaml | 81 +++++++++++++++++++ .../sailpoint/scripts/disable_account.py | 76 +++++++++++++++++ .../sailpoint/scripts/enable_account.py | 76 +++++++++++++++++ .../sailpoint/scripts/get_identity.py | 72 +++++++++++++++++ .../sailpoint/scripts/list_accounts.py | 68 ++++++++++++++++ .../sailpoint/scripts/list_identities.py | 68 ++++++++++++++++ .../sailpoint/scripts/test_connection.py | 67 +++++++++++++++ 7 files changed, 508 insertions(+) create mode 100644 integrations/sailpoint/manifest.yaml create mode 100644 integrations/sailpoint/scripts/disable_account.py create mode 100644 integrations/sailpoint/scripts/enable_account.py create mode 100644 integrations/sailpoint/scripts/get_identity.py create mode 100644 integrations/sailpoint/scripts/list_accounts.py create mode 100644 integrations/sailpoint/scripts/list_identities.py create mode 100644 integrations/sailpoint/scripts/test_connection.py diff --git a/integrations/sailpoint/manifest.yaml b/integrations/sailpoint/manifest.yaml new file mode 100644 index 0000000..2f0f0dd --- /dev/null +++ b/integrations/sailpoint/manifest.yaml @@ -0,0 +1,81 @@ +id: sailpoint +name: SailPoint IdentityNow +version: 1.0.0 +description: "SailPoint IdentityNow (API v3) — identity governance and containment: list and read identities, list accounts, and disable/enable an account. OAuth2 client-credentials authentication; stdlib-only, no extra Python dependencies." +changelog: "1.0.0 — Initial release: list/get identities, list accounts, disable/enable account." +category: identity + +# Per-instance configuration. Client credentials are exchanged for a bearer +# token at {base_url}/oauth/token; API calls go to {base_url}/v3. +config_schema: + properties: + base_url: + type: string + description: "IdentityNow API URL (e.g. https://tenant.api.identitynow.com)" + client_id: + type: string + description: "OAuth client ID" + client_secret: + type: string + description: "OAuth client secret" + x-soar-sensitive: true + required: + - base_url + - client_id + - client_secret + +commands: + - id: list_identities + name: sailpoint-list-identities + description: "List identities (optionally filtered)." + risk: read + inputs_schema: + properties: + filters: { type: string, description: "Filter expression (e.g. name eq \"john.doe\")" } + limit: { type: number, description: "Max identities (default 50)" } + required: [] + outputs_schema: { properties: {} } + - id: get_identity + name: sailpoint-get-identity + description: "Get a single identity by ID." + risk: read + inputs_schema: + properties: + identity_id: { type: string, description: "Identity ID" } + required: [identity_id] + outputs_schema: { properties: {} } + - id: list_accounts + name: sailpoint-list-accounts + description: "List accounts (optionally filtered)." + risk: read + inputs_schema: + properties: + filters: { type: string, description: "Filter expression (e.g. identityId eq \"...\")" } + limit: { type: number, description: "Max accounts (default 50)" } + required: [] + outputs_schema: { properties: {} } + - id: disable_account + name: sailpoint-disable-account + description: "Disable an account (containment)." + inputs_schema: + properties: + account_id: { type: string, description: "Account ID" } + required: [account_id] + outputs_schema: { properties: {} } + - id: enable_account + name: sailpoint-enable-account + description: "Enable an account." + inputs_schema: + properties: + account_id: { type: string, description: "Account ID" } + required: [account_id] + outputs_schema: { properties: {} } + + - id: test_connection + name: sailpoint-test-connection + description: "Verify credentials via the token exchange (used by the Test button)." + risk: read + inputs_schema: + properties: {} + required: [] + outputs_schema: { properties: {} } diff --git a/integrations/sailpoint/scripts/disable_account.py b/integrations/sailpoint/scripts/disable_account.py new file mode 100644 index 0000000..428d564 --- /dev/null +++ b/integrations/sailpoint/scripts/disable_account.py @@ -0,0 +1,76 @@ +import json, os, sys, urllib.parse, urllib.request, urllib.error + + +def _cfg(): + return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}")) + + +def _inputs(): + return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}")) + + +def _base(cfg): + return str(cfg.get("base_url", "")).rstrip("/") + + +def _token(cfg): + form = urllib.parse.urlencode({ + "grant_type": "client_credentials", + "client_id": str(cfg.get("client_id", "")), + "client_secret": str(cfg.get("client_secret", "")), + }).encode("utf-8") + req = urllib.request.Request(_base(cfg) + "/oauth/token", data=form, + headers={"Content-Type": "application/x-www-form-urlencoded", + "Accept": "application/json"}, method="POST") + with urllib.request.urlopen(req, timeout=60) as r: + tok = json.loads(r.read()) + if not tok.get("access_token"): + raise Exception("Token request failed: " + json.dumps(tok)) + return tok["access_token"] + + +def request(method, path, cfg, token, body=None, params=None): + url = _base(cfg) + "/v3" + path + if params: + clean = {k: v for k, v in params.items() if v not in (None, "")} + if clean: + url += "?" + urllib.parse.urlencode(clean) + data = json.dumps(body).encode("utf-8") if body is not None else None + headers = {"Authorization": "Bearer " + token, "Accept": "application/json"} + if data is not None: + headers["Content-Type"] = "application/json" + req = urllib.request.Request(url, data=data, headers=headers, method=method) + with urllib.request.urlopen(req, timeout=60) as r: + raw = r.read() + return json.loads(raw) if raw else {} + + +def _run(fn): + try: + cfg = _cfg() + inputs = _inputs() + token = _token(cfg) + print(json.dumps(fn(cfg, token, inputs))) + except urllib.error.HTTPError as e: + print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")})) + sys.exit(1) + except Exception as e: + print(json.dumps({"error": str(e)})) + sys.exit(1) + + +q = lambda v: urllib.parse.quote(str(v), safe="") + + +def main(cfg, token, inputs): + account_id = inputs.get("account_id") + if not account_id: + raise Exception("account_id is required") + resp = request("POST", "/accounts/" + q(account_id) + "/disable", cfg, token, + body={"externalVerificationId": None, "forceProvisioning": False}) + if not resp: + return {"ok": True, "account_id": account_id, "action": "disable"} + return resp + + +_run(main) diff --git a/integrations/sailpoint/scripts/enable_account.py b/integrations/sailpoint/scripts/enable_account.py new file mode 100644 index 0000000..43093ca --- /dev/null +++ b/integrations/sailpoint/scripts/enable_account.py @@ -0,0 +1,76 @@ +import json, os, sys, urllib.parse, urllib.request, urllib.error + + +def _cfg(): + return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}")) + + +def _inputs(): + return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}")) + + +def _base(cfg): + return str(cfg.get("base_url", "")).rstrip("/") + + +def _token(cfg): + form = urllib.parse.urlencode({ + "grant_type": "client_credentials", + "client_id": str(cfg.get("client_id", "")), + "client_secret": str(cfg.get("client_secret", "")), + }).encode("utf-8") + req = urllib.request.Request(_base(cfg) + "/oauth/token", data=form, + headers={"Content-Type": "application/x-www-form-urlencoded", + "Accept": "application/json"}, method="POST") + with urllib.request.urlopen(req, timeout=60) as r: + tok = json.loads(r.read()) + if not tok.get("access_token"): + raise Exception("Token request failed: " + json.dumps(tok)) + return tok["access_token"] + + +def request(method, path, cfg, token, body=None, params=None): + url = _base(cfg) + "/v3" + path + if params: + clean = {k: v for k, v in params.items() if v not in (None, "")} + if clean: + url += "?" + urllib.parse.urlencode(clean) + data = json.dumps(body).encode("utf-8") if body is not None else None + headers = {"Authorization": "Bearer " + token, "Accept": "application/json"} + if data is not None: + headers["Content-Type"] = "application/json" + req = urllib.request.Request(url, data=data, headers=headers, method=method) + with urllib.request.urlopen(req, timeout=60) as r: + raw = r.read() + return json.loads(raw) if raw else {} + + +def _run(fn): + try: + cfg = _cfg() + inputs = _inputs() + token = _token(cfg) + print(json.dumps(fn(cfg, token, inputs))) + except urllib.error.HTTPError as e: + print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")})) + sys.exit(1) + except Exception as e: + print(json.dumps({"error": str(e)})) + sys.exit(1) + + +q = lambda v: urllib.parse.quote(str(v), safe="") + + +def main(cfg, token, inputs): + account_id = inputs.get("account_id") + if not account_id: + raise Exception("account_id is required") + resp = request("POST", "/accounts/" + q(account_id) + "/enable", cfg, token, + body={"forceProvisioning": False}) + if not resp: + return {"ok": True, "account_id": account_id, "action": "enable"} + return resp + + +_run(main) diff --git a/integrations/sailpoint/scripts/get_identity.py b/integrations/sailpoint/scripts/get_identity.py new file mode 100644 index 0000000..2b870eb --- /dev/null +++ b/integrations/sailpoint/scripts/get_identity.py @@ -0,0 +1,72 @@ +import json, os, sys, urllib.parse, urllib.request, urllib.error + + +def _cfg(): + return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}")) + + +def _inputs(): + return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}")) + + +def _base(cfg): + return str(cfg.get("base_url", "")).rstrip("/") + + +def _token(cfg): + form = urllib.parse.urlencode({ + "grant_type": "client_credentials", + "client_id": str(cfg.get("client_id", "")), + "client_secret": str(cfg.get("client_secret", "")), + }).encode("utf-8") + req = urllib.request.Request(_base(cfg) + "/oauth/token", data=form, + headers={"Content-Type": "application/x-www-form-urlencoded", + "Accept": "application/json"}, method="POST") + with urllib.request.urlopen(req, timeout=60) as r: + tok = json.loads(r.read()) + if not tok.get("access_token"): + raise Exception("Token request failed: " + json.dumps(tok)) + return tok["access_token"] + + +def request(method, path, cfg, token, body=None, params=None): + url = _base(cfg) + "/v3" + path + if params: + clean = {k: v for k, v in params.items() if v not in (None, "")} + if clean: + url += "?" + urllib.parse.urlencode(clean) + data = json.dumps(body).encode("utf-8") if body is not None else None + headers = {"Authorization": "Bearer " + token, "Accept": "application/json"} + if data is not None: + headers["Content-Type"] = "application/json" + req = urllib.request.Request(url, data=data, headers=headers, method=method) + with urllib.request.urlopen(req, timeout=60) as r: + raw = r.read() + return json.loads(raw) if raw else {} + + +def _run(fn): + try: + cfg = _cfg() + inputs = _inputs() + token = _token(cfg) + print(json.dumps(fn(cfg, token, inputs))) + except urllib.error.HTTPError as e: + print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")})) + sys.exit(1) + except Exception as e: + print(json.dumps({"error": str(e)})) + sys.exit(1) + + +q = lambda v: urllib.parse.quote(str(v), safe="") + + +def main(cfg, token, inputs): + identity_id = inputs.get("identity_id") + if not identity_id: + raise Exception("identity_id is required") + return request("GET", "/identities/" + q(identity_id), cfg, token) + + +_run(main) diff --git a/integrations/sailpoint/scripts/list_accounts.py b/integrations/sailpoint/scripts/list_accounts.py new file mode 100644 index 0000000..88cfca7 --- /dev/null +++ b/integrations/sailpoint/scripts/list_accounts.py @@ -0,0 +1,68 @@ +import json, os, sys, urllib.parse, urllib.request, urllib.error + + +def _cfg(): + return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}")) + + +def _inputs(): + return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}")) + + +def _base(cfg): + return str(cfg.get("base_url", "")).rstrip("/") + + +def _token(cfg): + form = urllib.parse.urlencode({ + "grant_type": "client_credentials", + "client_id": str(cfg.get("client_id", "")), + "client_secret": str(cfg.get("client_secret", "")), + }).encode("utf-8") + req = urllib.request.Request(_base(cfg) + "/oauth/token", data=form, + headers={"Content-Type": "application/x-www-form-urlencoded", + "Accept": "application/json"}, method="POST") + with urllib.request.urlopen(req, timeout=60) as r: + tok = json.loads(r.read()) + if not tok.get("access_token"): + raise Exception("Token request failed: " + json.dumps(tok)) + return tok["access_token"] + + +def request(method, path, cfg, token, body=None, params=None): + url = _base(cfg) + "/v3" + path + if params: + clean = {k: v for k, v in params.items() if v not in (None, "")} + if clean: + url += "?" + urllib.parse.urlencode(clean) + data = json.dumps(body).encode("utf-8") if body is not None else None + headers = {"Authorization": "Bearer " + token, "Accept": "application/json"} + if data is not None: + headers["Content-Type"] = "application/json" + req = urllib.request.Request(url, data=data, headers=headers, method=method) + with urllib.request.urlopen(req, timeout=60) as r: + raw = r.read() + return json.loads(raw) if raw else {} + + +def _run(fn): + try: + cfg = _cfg() + inputs = _inputs() + token = _token(cfg) + print(json.dumps(fn(cfg, token, inputs))) + except urllib.error.HTTPError as e: + print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")})) + sys.exit(1) + except Exception as e: + print(json.dumps({"error": str(e)})) + sys.exit(1) + + +def main(cfg, token, inputs): + filters = inputs.get("filters") + limit = inputs.get("limit") + return request("GET", "/accounts", cfg, token, params={"filters": filters, "limit": int(limit or 50)}) + + +_run(main) diff --git a/integrations/sailpoint/scripts/list_identities.py b/integrations/sailpoint/scripts/list_identities.py new file mode 100644 index 0000000..92a65f0 --- /dev/null +++ b/integrations/sailpoint/scripts/list_identities.py @@ -0,0 +1,68 @@ +import json, os, sys, urllib.parse, urllib.request, urllib.error + + +def _cfg(): + return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}")) + + +def _inputs(): + return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}")) + + +def _base(cfg): + return str(cfg.get("base_url", "")).rstrip("/") + + +def _token(cfg): + form = urllib.parse.urlencode({ + "grant_type": "client_credentials", + "client_id": str(cfg.get("client_id", "")), + "client_secret": str(cfg.get("client_secret", "")), + }).encode("utf-8") + req = urllib.request.Request(_base(cfg) + "/oauth/token", data=form, + headers={"Content-Type": "application/x-www-form-urlencoded", + "Accept": "application/json"}, method="POST") + with urllib.request.urlopen(req, timeout=60) as r: + tok = json.loads(r.read()) + if not tok.get("access_token"): + raise Exception("Token request failed: " + json.dumps(tok)) + return tok["access_token"] + + +def request(method, path, cfg, token, body=None, params=None): + url = _base(cfg) + "/v3" + path + if params: + clean = {k: v for k, v in params.items() if v not in (None, "")} + if clean: + url += "?" + urllib.parse.urlencode(clean) + data = json.dumps(body).encode("utf-8") if body is not None else None + headers = {"Authorization": "Bearer " + token, "Accept": "application/json"} + if data is not None: + headers["Content-Type"] = "application/json" + req = urllib.request.Request(url, data=data, headers=headers, method=method) + with urllib.request.urlopen(req, timeout=60) as r: + raw = r.read() + return json.loads(raw) if raw else {} + + +def _run(fn): + try: + cfg = _cfg() + inputs = _inputs() + token = _token(cfg) + print(json.dumps(fn(cfg, token, inputs))) + except urllib.error.HTTPError as e: + print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")})) + sys.exit(1) + except Exception as e: + print(json.dumps({"error": str(e)})) + sys.exit(1) + + +def main(cfg, token, inputs): + filters = inputs.get("filters") + limit = inputs.get("limit") + return request("GET", "/public-identities", cfg, token, params={"filters": filters, "limit": int(limit or 50)}) + + +_run(main) diff --git a/integrations/sailpoint/scripts/test_connection.py b/integrations/sailpoint/scripts/test_connection.py new file mode 100644 index 0000000..8607fd3 --- /dev/null +++ b/integrations/sailpoint/scripts/test_connection.py @@ -0,0 +1,67 @@ +import json, os, sys, urllib.parse, urllib.request, urllib.error + + +def _cfg(): + return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}")) + + +def _inputs(): + return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}")) + + +def _base(cfg): + return str(cfg.get("base_url", "")).rstrip("/") + + +def _token(cfg): + form = urllib.parse.urlencode({ + "grant_type": "client_credentials", + "client_id": str(cfg.get("client_id", "")), + "client_secret": str(cfg.get("client_secret", "")), + }).encode("utf-8") + req = urllib.request.Request(_base(cfg) + "/oauth/token", data=form, + headers={"Content-Type": "application/x-www-form-urlencoded", + "Accept": "application/json"}, method="POST") + with urllib.request.urlopen(req, timeout=60) as r: + tok = json.loads(r.read()) + if not tok.get("access_token"): + raise Exception("Token request failed: " + json.dumps(tok)) + return tok["access_token"] + + +def request(method, path, cfg, token, body=None, params=None): + url = _base(cfg) + "/v3" + path + if params: + clean = {k: v for k, v in params.items() if v not in (None, "")} + if clean: + url += "?" + urllib.parse.urlencode(clean) + data = json.dumps(body).encode("utf-8") if body is not None else None + headers = {"Authorization": "Bearer " + token, "Accept": "application/json"} + if data is not None: + headers["Content-Type"] = "application/json" + req = urllib.request.Request(url, data=data, headers=headers, method=method) + with urllib.request.urlopen(req, timeout=60) as r: + raw = r.read() + return json.loads(raw) if raw else {} + + +def _run(fn): + try: + cfg = _cfg() + inputs = _inputs() + token = _token(cfg) + print(json.dumps(fn(cfg, token, inputs))) + except urllib.error.HTTPError as e: + print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")})) + sys.exit(1) + except Exception as e: + print(json.dumps({"error": str(e)})) + sys.exit(1) + + +def main(cfg, token, inputs): + request("GET", "/public-identities", cfg, token, params={"limit": 1}) + return {"ok": True} + + +_run(main)