Skip to content

Ministack: Free, open-source local AWS emulator - 60+ services, Terraform compatible, real databases. Free forever. MIT licensed.

feat(iam): SAML provider CRUD + ListOpenIDConnectProviders (#847)

lahmish64df3e4e91e0
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7783b2fd..a9a67c62 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,10 @@ Versioning follows [Semantic Versioning](https://semver.org/).
## [Unreleased]
### Added
+- **IAM — `CreateSAMLProvider`, `GetSAMLProvider`, `ListSAMLProviders`, `UpdateSAMLProvider`, `DeleteSAMLProvider`** — SAML IdP CRUD. Accepts any non-empty `SAMLMetadataDocument` (real AWS requires valid XML ≥1000 chars; that validation is seed-side). `GetSAMLProvider` returns `SAMLMetadataDocument`, `CreateDate`, `ValidUntil`, and `Tags`. Enables agents to enumerate federated IdPs cross-referenced with role trust policies.
+- **IAM — `ListOpenIDConnectProviders`** — returns `{Arn}` entries for all OIDC providers in the account (create/get/delete existed previously). Completes the OIDC provider enumeration surface.
+
+---
- **IAM — `GetAccountAuthorizationDetails`** — the one-shot identity graph. Returns `UserDetailList` (inline policies, attached managed policies, group memberships, tags), `GroupDetailList`, `RoleDetailList` (inline policies, attached managed policies, instance profiles, tags, assume-role document url-encoded), and `Policies` (customer-managed, with url-encoded version documents). `Filter.member.N` honored: `User`, `Group`, `Role`, `LocalManagedPolicy`. `IsTruncated=false`; pagination optional.
---
diff --git a/README.md b/README.md
index c4a924ab..b4c4b14d 100644
--- a/README.md
+++ b/README.md
@@ -356,6 +356,7 @@ subnet = ec2.create_subnet(
| **DynamoDB** | CreateTable, UpdateTable, DeleteTable, DescribeTable, ListTables, PutItem, GetItem, DeleteItem, UpdateItem, Query, Scan, BatchWriteItem, BatchGetItem, TransactWriteItems, TransactGetItems, DescribeTimeToLive, UpdateTimeToLive, DescribeContinuousBackups, UpdateContinuousBackups, DescribeEndpoints, TagResource, UntagResource, ListTagsOfResource, EnableKinesisStreamingDestination, DisableKinesisStreamingDestination, DescribeKinesisStreamingDestination, UpdateKinesisStreamingDestination | TTL enforced via thread-safe background reaper (60s cadence); DynamoDB Streams — `StreamSpecification` emits INSERT/MODIFY/REMOVE records on all write operations, respects `StreamViewType`; Kinesis streaming destinations (`aws_dynamodb_kinesis_streaming_destination`) fan item mutations out into any Kinesis stream by ARN while the destination is ACTIVE |
| **DynamoDB Streams** | ListStreams, DescribeStream, GetShardIterator, GetRecords | Reads records emitted by the main DynamoDB service via `boto3.client("dynamodbstreams")` — single synthetic shard per stream; `TRIM_HORIZON`/`LATEST`/`AT_SEQUENCE_NUMBER`/`AFTER_SEQUENCE_NUMBER` iterator types; `NEW_AND_OLD_IMAGES`, `NEW_IMAGE`, `OLD_IMAGE`, `KEYS_ONLY` view types; opaque base64 iterator tokens |
| **Lambda** | CreateFunction, DeleteFunction, GetFunction, GetFunctionConfiguration, ListFunctions, Invoke, UpdateFunctionCode, UpdateFunctionConfiguration, AddPermission, RemovePermission, GetPolicy, ListVersionsByFunction, PublishVersion, CreateAlias, GetAlias, UpdateAlias, DeleteAlias, ListAliases, TagResource, UntagResource, ListTags, CreateEventSourceMapping, DeleteEventSourceMapping, GetEventSourceMapping, ListEventSourceMappings, UpdateEventSourceMapping, CreateFunctionUrlConfig, GetFunctionUrlConfig, UpdateFunctionUrlConfig, DeleteFunctionUrlConfig, ListFunctionUrlConfigs, PutFunctionConcurrency, GetFunctionConcurrency, DeleteFunctionConcurrency, PutFunctionEventInvokeConfig, GetFunctionEventInvokeConfig, DeleteFunctionEventInvokeConfig, PublishLayerVersion, GetLayerVersion, GetLayerVersionByArn, ListLayerVersions, DeleteLayerVersion, ListLayers, AddLayerVersionPermission, RemoveLayerVersionPermission, GetLayerVersionPolicy, CheckpointDurableExecution, GetDurableExecution, GetDurableExecutionState, GetDurableExecutionHistory, ListDurableExecutionsByFunction, StopDurableExecution, SendDurableExecutionCallbackSuccess, SendDurableExecutionCallbackFailure, SendDurableExecutionCallbackHeartbeat | Python and Node.js runtimes execute with warm worker pool; `provided.al2023`/`provided.al2` runtimes execute via Docker RIE (Go, Rust, C++ support); `Publish=True` creates immutable numbered versions; Code via `ZipFile`, `S3Bucket`/`S3Key` (with optional `S3ObjectVersion`), or `ImageUri` (Docker image); `PackageType: Image` pulls and invokes user-provided Docker images via Lambda RIE; SQS, Kinesis, and DynamoDB Streams event source mappings; Function URL CRUD; Lambda Layers CRUD; Aliases; Concurrency; EventInvokeConfig; **Durable Functions** — `CreateFunction` accepts `DurableConfig`; checkpoint/state/history/list/stop ops at the preview API (`2025-12-01`); external `SendCallback{Success,Failure,Heartbeat}` resume the SDK across invocations; resume scheduler fires WAIT expiries, callback timeouts, and step-retry backoffs; verified against the official `aws-durable-execution-sdk-python` and `aws-durable-execution-sdk-java`; **X-Ray active tracing** — `TracingConfig.Mode=Active` injects `_X_AMZN_TRACE_ID` (`Root=1-<hex>-<hex>;Parent=<hex>;Sampled=1`) into the runtime per invocation so the AWS X-Ray SDK runs without `Missing AWS Lambda trace data`; supported on the warm Python / Node executor, provided runtimes, and the local subprocess fallback (docker RIE upstream does not implement X-Ray and is logged but unsupported) |
+| **IAM** | CreateUser, GetUser, ListUsers, DeleteUser, CreateRole, GetRole, ListRoles, DeleteRole, CreatePolicy, GetPolicy, DeletePolicy, AttachRolePolicy, DetachRolePolicy, PutRolePolicy, GetRolePolicy, DeleteRolePolicy, ListRolePolicies, ListAttachedRolePolicies, CreateAccessKey, ListAccessKeys, DeleteAccessKey, UpdateAccessKey, GetAccessKeyLastUsed, CreateInstanceProfile, GetInstanceProfile, DeleteInstanceProfile, AddRoleToInstanceProfile, RemoveRoleFromInstanceProfile, ListInstanceProfiles, CreateGroup, GetGroup, AddUserToGroup, RemoveUserFromGroup, CreateServiceLinkedRole, DeleteServiceLinkedRole, GetServiceLinkedRoleDeletionStatus, CreateOpenIDConnectProvider, TagRole, UntagRole, TagUser, UntagUser, TagPolicy, UntagPolicy, CreateSAMLProvider, GetSAMLProvider, ListSAMLProviders, UpdateSAMLProvider, DeleteSAMLProvider, ListOpenIDConnectProviders | |
| **IAM** | CreateUser, GetUser, ListUsers, DeleteUser, CreateRole, GetRole, ListRoles, DeleteRole, CreatePolicy, GetPolicy, DeletePolicy, AttachRolePolicy, DetachRolePolicy, PutRolePolicy, GetRolePolicy, DeleteRolePolicy, ListRolePolicies, ListAttachedRolePolicies, CreateAccessKey, ListAccessKeys, DeleteAccessKey, UpdateAccessKey, GetAccessKeyLastUsed, CreateInstanceProfile, GetInstanceProfile, DeleteInstanceProfile, AddRoleToInstanceProfile, RemoveRoleFromInstanceProfile, ListInstanceProfiles, CreateGroup, GetGroup, AddUserToGroup, RemoveUserFromGroup, CreateServiceLinkedRole, DeleteServiceLinkedRole, GetServiceLinkedRoleDeletionStatus, CreateOpenIDConnectProvider, TagRole, UntagRole, TagUser, UntagUser, TagPolicy, UntagPolicy, GetAccountAuthorizationDetails | |
| **IAM** | CreateUser, GetUser, ListUsers, DeleteUser, CreateRole, GetRole, ListRoles, DeleteRole, CreatePolicy, GetPolicy, DeletePolicy, AttachRolePolicy, DetachRolePolicy, PutRolePolicy, GetRolePolicy, DeleteRolePolicy, ListRolePolicies, ListAttachedRolePolicies, CreateAccessKey, ListAccessKeys, DeleteAccessKey, UpdateAccessKey, GetAccessKeyLastUsed, CreateInstanceProfile, GetInstanceProfile, DeleteInstanceProfile, AddRoleToInstanceProfile, RemoveRoleFromInstanceProfile, ListInstanceProfiles, CreateGroup, GetGroup, AddUserToGroup, RemoveUserFromGroup, CreateServiceLinkedRole, DeleteServiceLinkedRole, GetServiceLinkedRoleDeletionStatus, CreateOpenIDConnectProvider, TagRole, UntagRole, TagUser, UntagUser, TagPolicy, UntagPolicy, CreateVirtualMFADevice, EnableMFADevice, DeactivateMFADevice, ResyncMFADevice, ListMFADevices, ListVirtualMFADevices, DeleteVirtualMFADevice | |
| **IAM** | CreateUser, GetUser, ListUsers, DeleteUser, CreateRole, GetRole, ListRoles, DeleteRole, CreatePolicy, GetPolicy, DeletePolicy, AttachRolePolicy, DetachRolePolicy, PutRolePolicy, GetRolePolicy, DeleteRolePolicy, ListRolePolicies, ListAttachedRolePolicies, CreateAccessKey, ListAccessKeys, DeleteAccessKey, UpdateAccessKey, GetAccessKeyLastUsed, CreateInstanceProfile, GetInstanceProfile, DeleteInstanceProfile, AddRoleToInstanceProfile, RemoveRoleFromInstanceProfile, ListInstanceProfiles, CreateGroup, GetGroup, AddUserToGroup, RemoveUserFromGroup, CreateServiceLinkedRole, DeleteServiceLinkedRole, GetServiceLinkedRoleDeletionStatus, CreateOpenIDConnectProvider, TagRole, UntagRole, TagUser, UntagUser, TagPolicy, UntagPolicy, CreateLoginProfile, GetLoginProfile, UpdateLoginProfile, DeleteLoginProfile | |
diff --git a/ministack/services/iam.py b/ministack/services/iam.py
index aecfa961..d8a5417a 100644
--- a/ministack/services/iam.py
+++ b/ministack/services/iam.py
@@ -35,6 +35,7 @@ import os
import time
from urllib.parse import parse_qs
from urllib.parse import quote as _url_quote
+from xml.sax.saxutils import escape as _xml_escape
from ministack.core.responses import AccountScopedDict, get_account_id, get_region, json_response, new_uuid
@@ -56,6 +57,7 @@ _groups = AccountScopedDict()
_user_inline_policies = AccountScopedDict()
_oidc_providers = AccountScopedDict()
_service_linked_role_deletion_tasks = AccountScopedDict()
+_saml_providers = AccountScopedDict()
_mfa_devices = AccountScopedDict()
_login_profiles = AccountScopedDict()
@@ -284,6 +286,7 @@ def get_state():
"service_linked_role_deletion_tasks": copy.deepcopy(_service_linked_role_deletion_tasks),
"user_inline_policies": copy.deepcopy(_user_inline_policies),
"aws_managed_attachment_counts": copy.deepcopy(_aws_managed_attachment_counts),
+ "saml_providers": copy.deepcopy(_saml_providers),
"mfa_devices": copy.deepcopy(_mfa_devices),
"login_profiles": copy.deepcopy(_login_profiles),
}
@@ -301,6 +304,7 @@ def restore_state(data):
_service_linked_role_deletion_tasks.update(data.get("service_linked_role_deletion_tasks", {}))
_user_inline_policies.update(data.get("user_inline_policies", {}))
_aws_managed_attachment_counts.update(data.get("aws_managed_attachment_counts", {}))
+ _saml_providers.update(data.get("saml_providers", {}))
_mfa_devices.update(data.get("mfa_devices", {}))
_login_profiles.update(data.get("login_profiles", {}))
@@ -1973,6 +1977,103 @@ def _delete_oidc_provider(p):
return _xml(200, "DeleteOpenIDConnectProviderResponse", "", ns="iam")
+def _list_oidc_providers(p):
+ members = "".join(
+ f"<member><Arn>{arn}</Arn></member>"
+ for arn in _oidc_providers
+ )
+ return _xml(200, "ListOpenIDConnectProvidersResponse",
+ f"<ListOpenIDConnectProvidersResult>"
+ f"<OpenIDConnectProviderList>{members}</OpenIDConnectProviderList>"
+ f"</ListOpenIDConnectProvidersResult>",
+ ns="iam")
+
+
+# -------------------- SAML providers --------------------
+
+
+def _create_saml_provider(p):
+ name = _p(p, "Name")
+ acct = get_account_id()
+ arn = f"arn:aws:iam::{acct}:saml-provider/{name}"
+ if arn in _saml_providers:
+ return _error(409, "EntityAlreadyExists",
+ f"SAML provider {arn} already exists.", ns="iam")
+ metadata = _p(p, "SAMLMetadataDocument")
+ _saml_providers[arn] = {
+ "Arn": arn,
+ "Name": name,
+ "SAMLMetadataDocument": metadata,
+ "CreateDate": _now(),
+ "ValidUntil": _future(365 * 24 * 3600),
+ "Tags": _extract_tags(p),
+ }
+ return _xml(200, "CreateSAMLProviderResponse",
+ f"<CreateSAMLProviderResult>"
+ f"<SAMLProviderArn>{arn}</SAMLProviderArn>"
+ f"</CreateSAMLProviderResult>",
+ ns="iam")
+
+
+def _get_saml_provider(p):
+ arn = _p(p, "SAMLProviderArn")
+ prov = _saml_providers.get(arn)
+ if not prov:
+ return _error(404, "NoSuchEntity",
+ f"SAML provider {arn} not found.", ns="iam")
+ tag_members = "".join(
+ f"<member><Key>{t['Key']}</Key><Value>{t['Value']}</Value></member>"
+ for t in prov.get("Tags", [])
+ )
+ return _xml(200, "GetSAMLProviderResponse",
+ f"<GetSAMLProviderResult>"
+ f"<SAMLMetadataDocument>{_xml_escape(prov['SAMLMetadataDocument'])}</SAMLMetadataDocument>"
+ f"<CreateDate>{prov['CreateDate']}</CreateDate>"
+ f"<ValidUntil>{prov['ValidUntil']}</ValidUntil>"
+ f"<Tags>{tag_members}</Tags>"
+ f"</GetSAMLProviderResult>",
+ ns="iam")
+
+
+def _list_saml_providers(p):
+ members = "".join(
+ f"<member>"
+ f"<Arn>{prov['Arn']}</Arn>"
+ f"<ValidUntil>{prov['ValidUntil']}</ValidUntil>"
+ f"<CreateDate>{prov['CreateDate']}</CreateDate>"
+ f"</member>"
+ for prov in _saml_providers.values()
+ )
+ return _xml(200, "ListSAMLProvidersResponse",
+ f"<ListSAMLProvidersResult>"
+ f"<SAMLProviderList>{members}</SAMLProviderList>"
+ f"</ListSAMLProvidersResult>",
+ ns="iam")
+
+
+def _update_saml_provider(p):
+ arn = _p(p, "SAMLProviderArn")
+ prov = _saml_providers.get(arn)
+ if not prov:
+ return _error(404, "NoSuchEntity",
+ f"SAML provider {arn} not found.", ns="iam")
+ prov["SAMLMetadataDocument"] = _p(p, "SAMLMetadataDocument")
+ return _xml(200, "UpdateSAMLProviderResponse",
+ f"<UpdateSAMLProviderResult>"
+ f"<SAMLProviderArn>{arn}</SAMLProviderArn>"
+ f"</UpdateSAMLProviderResult>",
+ ns="iam")
+
+
+def _delete_saml_provider(p):
+ arn = _p(p, "SAMLProviderArn")
+ if arn not in _saml_providers:
+ return _error(404, "NoSuchEntity",
+ f"SAML provider {arn} not found.", ns="iam")
+ del _saml_providers[arn]
+ return _xml(200, "DeleteSAMLProviderResponse", "", ns="iam")
+
+
# -------------------- Tags: policies --------------------
def _tag_policy(p):
@@ -2284,6 +2385,12 @@ _IAM_HANDLERS = {
"CreateOpenIDConnectProvider": _create_oidc_provider,
"GetOpenIDConnectProvider": _get_oidc_provider,
"DeleteOpenIDConnectProvider": _delete_oidc_provider,
+ "CreateSAMLProvider": _create_saml_provider,
+ "GetSAMLProvider": _get_saml_provider,
+ "ListSAMLProviders": _list_saml_providers,
+ "UpdateSAMLProvider": _update_saml_provider,
+ "DeleteSAMLProvider": _delete_saml_provider,
+ "ListOpenIDConnectProviders": _list_oidc_providers,
"GetAccountAuthorizationDetails": _get_account_authorization_details,
"CreateVirtualMFADevice": _create_virtual_mfa_device,
"EnableMFADevice": _enable_mfa_device,
@@ -2312,6 +2419,7 @@ def reset():
_user_inline_policies.clear()
_oidc_providers.clear()
_service_linked_role_deletion_tasks.clear()
+ _saml_providers.clear()
_mfa_devices.clear()
_login_profiles.clear()
# Re-seed AWS-managed policies. They're not customer state, so a
diff --git a/tests/test_iam.py b/tests/test_iam.py
index b339a16d..59400345 100644
--- a/tests/test_iam.py
+++ b/tests/test_iam.py
@@ -737,6 +737,40 @@ def test_iam_aws_managed_attachment_count_persists_through_state_round_trip():
assert _iam._aws_managed_attachment_counts.get(arn) == 2
+# ── SAML providers + ListOpenIDConnectProviders ──────────────────────
+
+
+def test_iam_saml_provider_crud(iam):
+ name = "saml-test-provider"
+ # botocore requires ≥ 1000 chars for SAMLMetadataDocument (client-side validation)
+ metadata = "<EntityDescriptor>" + "x" * 990 + "</EntityDescriptor>"
+ resp = iam.create_saml_provider(Name=name, SAMLMetadataDocument=metadata)
+ arn = resp["SAMLProviderArn"]
+ assert f":saml-provider/{name}" in arn
+
+ providers = iam.list_saml_providers()["SAMLProviderList"]
+ assert any(p["Arn"] == arn for p in providers)
+
+ get_resp = iam.get_saml_provider(SAMLProviderArn=arn)
+ assert get_resp["SAMLMetadataDocument"] == metadata
+
+ iam.delete_saml_provider(SAMLProviderArn=arn)
+ with pytest.raises(iam.exceptions.NoSuchEntityException):
+ iam.get_saml_provider(SAMLProviderArn=arn)
+
+
+def test_iam_list_oidc_providers(iam):
+ resp = iam.create_open_id_connect_provider(
+ Url="https://oidc-list-test.example.com",
+ ClientIDList=["aud"],
+ ThumbprintList=["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa00"],
+ )
+ arn = resp["OpenIDConnectProviderArn"]
+ try:
+ providers = iam.list_open_id_connect_providers()["OpenIDConnectProviderList"]
+ assert any(p["Arn"] == arn for p in providers)
+ finally:
+ iam.delete_open_id_connect_provider(OpenIDConnectProviderArn=arn)
# ── GetAccountAuthorizationDetails ───────────────────────────────────