Skip to content

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

fix(cognito): AdminListUserAuthEvents requires user-pool add-ons (#1538)

iot-rocket1feade046c3d
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e83e6f67..d01a4eff 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,7 @@ Versioning follows [Semantic Versioning](https://semver.org/).
### Fixed
- **Aurora DSQL — the `ALTER TABLE` refusals answer what the service answers** — measuring the emulator against a live cluster (eu-central-1, 2026-08-30) found four statements answered differently. A refused `ADD CONSTRAINT` — `PRIMARY KEY`, an inline `UNIQUE`, `EXCLUDE`, or a `CHECK`/`FOREIGN KEY` without `NOT VALID` — drew three invented messages where DSQL answers one, `unsupported ALTER TABLE ADD CONSTRAINT statement`. `ADD COLUMN` refused only `DEFAULT` and `NOT NULL` and let `REFERENCES`, `UNIQUE`, `CHECK`, `GENERATED ... STORED` and an inline identity through, where DSQL takes `name type [STORAGE mode]` and nothing else (`ALTER TABLE ADD COLUMN with constraint not supported`, a bare `NULL` apart, and `COLLATE clause not supported` for a collation); `ALTER COLUMN ... ADD GENERATED AS IDENTITY` on an existing column is unaffected. `ALTER TABLE ASYNC ... VALIDATE CONSTRAINT` over rows that break the constraint relayed the backend's `23503` at submit time, where DSQL hands back a `job_id` and fails the job — `sys.jobs` now reports `failed` with the violation as `details` and `sys.wait_for_job` answers false. Adding several columns in one statement also read the second action as part of the first column's type. Contributed by @vivedo.
+- **Cognito — `AdminListUserAuthEvents` requires user-pool add-ons, as real Cognito does** — the call answered `{"AuthEvents": []}` for every pool, but AWS refuses it with `UserPoolAddOnNotEnabledException` (400) unless the pool's `UserPoolAddOns.AdvancedSecurityMode` is enabled; the permissive empty list let caller bugs an add-ons check would surface — such as indexing into the events unguarded — pass locally and fail against real AWS. The stored `UserPoolAddOns` now gates the operation; with add-ons enabled the answer stays an empty list, since auth events are never recorded. Contributed by @iot-rocket.
## [1.5.3] — 2026-08-28
diff --git a/README.md b/README.md
index 7d8b7358..04ca4b45 100644
--- a/README.md
+++ b/README.md
@@ -576,7 +576,7 @@ MiniStack expands AWS SAM transforms (`Transform: AWS::Serverless-2016-10-31`) i
| **EBS** | CreateVolume, DeleteVolume, DescribeVolumes, DescribeVolumeStatus, AttachVolume, DetachVolume, ModifyVolume, DescribeVolumesModifications, EnableVolumeIO, ModifyVolumeAttribute, DescribeVolumeAttribute, CreateSnapshot, DeleteSnapshot, DescribeSnapshots, CopySnapshot, ModifySnapshotAttribute, DescribeSnapshotAttribute | Part of EC2 Query/XML service; attach/detach updates volume state; snapshots stored as completed immediately; Pro-only on LocalStack — free here |
| **EFS** | CreateFileSystem, DescribeFileSystems, DeleteFileSystem, UpdateFileSystem, CreateMountTarget, DescribeMountTargets, DeleteMountTarget, DescribeMountTargetSecurityGroups, ModifyMountTargetSecurityGroups, CreateAccessPoint, DescribeAccessPoints, DeleteAccessPoint, TagResource, UntagResource, ListTagsForResource, PutLifecycleConfiguration, DescribeLifecycleConfiguration, PutBackupPolicy, DescribeBackupPolicy, DescribeAccountPreferences, PutAccountPreferences | REST/JSON `/2015-02-01/*`; CreationToken idempotency; FileSystem deletion blocked when mount targets exist; Pro-only on LocalStack — free here |
| **EMR** | RunJobFlow, DescribeCluster, ListClusters, TerminateJobFlows, ModifyCluster, SetTerminationProtection, SetVisibleToAllUsers, AddJobFlowSteps, DescribeStep, ListSteps, CancelSteps, AddInstanceFleet, ListInstanceFleets, ModifyInstanceFleet, AddInstanceGroups, ListInstanceGroups, ModifyInstanceGroups, ListBootstrapActions, AddTags, RemoveTags, GetBlockPublicAccessConfiguration, PutBlockPublicAccessConfiguration | Control plane only — no real Spark/Hadoop; clusters start in WAITING (KeepAlive=true) or TERMINATED (KeepAlive=false); steps stored as COMPLETED immediately; all three instance modes (simple, InstanceGroups, InstanceFleets); TerminationProtected enforced; Pro-only on LocalStack — free here |
-| **Cognito** | **User Pools**: CreateUserPool, DeleteUserPool, DescribeUserPool, ListUserPools, UpdateUserPool, CreateUserPoolClient, DeleteUserPoolClient, DescribeUserPoolClient, ListUserPoolClients, UpdateUserPoolClient, CreateResourceServer, UpdateResourceServer, DescribeResourceServer, DeleteResourceServer, ListResourceServers, AdminCreateUser, AdminDeleteUser, AdminGetUser, ListUsers, AdminSetUserPassword, AdminUpdateUserAttributes, AdminConfirmSignUp, AdminDisableUser, AdminEnableUser, AdminResetUserPassword, AdminUserGlobalSignOut, AdminAddUserToGroup, AdminRemoveUserFromGroup, AdminListGroupsForUser, AdminListUserAuthEvents, AdminInitiateAuth, AdminRespondToAuthChallenge, InitiateAuth, RespondToAuthChallenge, GlobalSignOut, RevokeToken, SignUp, ConfirmSignUp, ForgotPassword, ConfirmForgotPassword, ChangePassword, GetUser, UpdateUserAttributes, DeleteUser, CreateGroup, DeleteGroup, GetGroup, ListGroups, ListUsersInGroup, CreateUserPoolDomain, DeleteUserPoolDomain, DescribeUserPoolDomain, GetUserPoolMfaConfig, SetUserPoolMfaConfig, AssociateSoftwareToken, VerifySoftwareToken, AdminSetUserMFAPreference, SetUserMFAPreference, CreateIdentityProvider, DescribeIdentityProvider, UpdateIdentityProvider, DeleteIdentityProvider, ListIdentityProviders, GetIdentityProviderByIdentifier, AdminLinkProviderForUser, AdminDisableProviderForUser, TagResource, UntagResource, ListTagsForResource; **Identity Pools**: CreateIdentityPool, DeleteIdentityPool, DescribeIdentityPool, ListIdentityPools, UpdateIdentityPool, GetId, GetCredentialsForIdentity, GetOpenIdToken, SetIdentityPoolRoles, GetIdentityPoolRoles, ListIdentities, DescribeIdentity, MergeDeveloperIdentities, UnlinkDeveloperIdentity, UnlinkIdentity, TagResource, UntagResource, ListTagsForResource; **OAuth2**: /oauth2/token (client_credentials) | Stub JWT tokens (structurally valid base64url JWTs); SRP auth returns PASSWORD_VERIFIER challenge; **CUSTOM_AUTH flow** wired through the configured `DefineAuthChallenge` / `CreateAuthChallenge` / `VerifyAuthChallengeResponse` Lambda triggers (passwordless / magic-link / SMS-OTP); session TTL honors `AuthSessionValidity`, capped at 3 answered rounds per AWS; confirmation codes hardcoded (signup: 123456, forgot-password: 654321); TOTP SOFTWARE_TOKEN_MFA challenge flow; MFA config and per-user enrollment stored in-memory; **user pool domains**: `CreateUserPoolDomain` with `CustomDomainConfig` registers a custom domain served on its own FQDN (without it, `Domain` is a prefix expanded to `{prefix}.auth.{region}.amazoncognito.com`), and the SAML ACS URL and OIDC federation callback are built from it — set one when MiniStack is reached through an external TLS terminator, so external IdPs get a reachable `https://{domain}/oauth2/idpresponse` instead of the internal gateway address; **federated user linking**: `AdminLinkProviderForUser` links an external identity to an existing profile before its first sign-in, so that sign-in resolves to the linked profile instead of minting a second `{Provider}_id` one, and the profile carries the `identities` attribute (also an ID-token claim) |
+| **Cognito** | **User Pools**: CreateUserPool, DeleteUserPool, DescribeUserPool, ListUserPools, UpdateUserPool, CreateUserPoolClient, DeleteUserPoolClient, DescribeUserPoolClient, ListUserPoolClients, UpdateUserPoolClient, CreateResourceServer, UpdateResourceServer, DescribeResourceServer, DeleteResourceServer, ListResourceServers, AdminCreateUser, AdminDeleteUser, AdminGetUser, ListUsers, AdminSetUserPassword, AdminUpdateUserAttributes, AdminConfirmSignUp, AdminDisableUser, AdminEnableUser, AdminResetUserPassword, AdminUserGlobalSignOut, AdminAddUserToGroup, AdminRemoveUserFromGroup, AdminListGroupsForUser, AdminListUserAuthEvents, AdminInitiateAuth, AdminRespondToAuthChallenge, InitiateAuth, RespondToAuthChallenge, GlobalSignOut, RevokeToken, SignUp, ConfirmSignUp, ForgotPassword, ConfirmForgotPassword, ChangePassword, GetUser, UpdateUserAttributes, DeleteUser, CreateGroup, DeleteGroup, GetGroup, ListGroups, ListUsersInGroup, CreateUserPoolDomain, DeleteUserPoolDomain, DescribeUserPoolDomain, GetUserPoolMfaConfig, SetUserPoolMfaConfig, AssociateSoftwareToken, VerifySoftwareToken, AdminSetUserMFAPreference, SetUserMFAPreference, CreateIdentityProvider, DescribeIdentityProvider, UpdateIdentityProvider, DeleteIdentityProvider, ListIdentityProviders, GetIdentityProviderByIdentifier, AdminLinkProviderForUser, AdminDisableProviderForUser, TagResource, UntagResource, ListTagsForResource; **Identity Pools**: CreateIdentityPool, DeleteIdentityPool, DescribeIdentityPool, ListIdentityPools, UpdateIdentityPool, GetId, GetCredentialsForIdentity, GetOpenIdToken, SetIdentityPoolRoles, GetIdentityPoolRoles, ListIdentities, DescribeIdentity, MergeDeveloperIdentities, UnlinkDeveloperIdentity, UnlinkIdentity, TagResource, UntagResource, ListTagsForResource; **OAuth2**: /oauth2/token (client_credentials) | Stub JWT tokens (structurally valid base64url JWTs); SRP auth returns PASSWORD_VERIFIER challenge; **CUSTOM_AUTH flow** wired through the configured `DefineAuthChallenge` / `CreateAuthChallenge` / `VerifyAuthChallengeResponse` Lambda triggers (passwordless / magic-link / SMS-OTP); session TTL honors `AuthSessionValidity`, capped at 3 answered rounds per AWS; confirmation codes hardcoded (signup: 123456, forgot-password: 654321); TOTP SOFTWARE_TOKEN_MFA challenge flow; MFA config and per-user enrollment stored in-memory; **user pool domains**: `CreateUserPoolDomain` with `CustomDomainConfig` registers a custom domain served on its own FQDN (without it, `Domain` is a prefix expanded to `{prefix}.auth.{region}.amazoncognito.com`), and the SAML ACS URL and OIDC federation callback are built from it — set one when MiniStack is reached through an external TLS terminator, so external IdPs get a reachable `https://{domain}/oauth2/idpresponse` instead of the internal gateway address; **federated user linking**: `AdminLinkProviderForUser` links an external identity to an existing profile before its first sign-in, so that sign-in resolves to the linked profile instead of minting a second `{Provider}_id` one, and the profile carries the `identities` attribute (also an ID-token claim); `AdminListUserAuthEvents` requires `UserPoolAddOns.AdvancedSecurityMode` != `OFF`, else `UserPoolAddOnNotEnabledException` as on AWS — events themselves are never recorded, so the answer is always an empty list |
| **ECR** | CreateRepository, DescribeRepositories, DeleteRepository, ListImages, DescribeImages, PutImage, BatchGetImage, BatchDeleteImage, GetAuthorizationToken, GetRepositoryPolicy, SetRepositoryPolicy, DeleteRepositoryPolicy, PutLifecyclePolicy, GetLifecyclePolicy, DeleteLifecyclePolicy, ListTagsForResource, TagResource, UntagResource, PutImageTagMutability, PutImageScanningConfiguration, DescribeRegistry, GetDownloadUrlForLayer, BatchCheckLayerAvailability, InitiateLayerUpload, UploadLayerPart, CompleteLayerUpload | In-memory image registry; Docker V2 manifest support; authorization token generation; lifecycle policies; tag mutability; Pro-only on LocalStack — free here |
| **AppSync** | **GraphQL APIs**: CreateGraphQLApi, GetGraphQLApi, ListGraphQLApis, UpdateGraphQLApi, DeleteGraphQLApi, CreateApiKey, DeleteApiKey, ListApiKeys, CreateDataSource, GetDataSource, ListDataSources, DeleteDataSource, CreateResolver, GetResolver, ListResolvers, DeleteResolver, CreateType, ListTypes, GetType, TagResource, UntagResource, ListTagsForResource; **Event APIs**: CreateApi, GetApi, ListApis, UpdateApi, DeleteApi, CreateChannelNamespace, GetChannelNamespace, ListChannelNamespaces, UpdateChannelNamespace, DeleteChannelNamespace, CreateApiKey, ListApiKeys, DeleteApiKey, HTTP Publish, WebSocket subscribe/publish | GraphQL queries/mutations execute against DynamoDB resolvers; Lambda resolvers supported. Event APIs support AWS-shaped `/v2/apis` management, `/v1/apis/{apiId}/apikeys` API-key operations, `POST /event` on `*.appsync-api.*`, and realtime `*.appsync-realtime-api.*` WebSocket flows with API-key and Lambda-authorizer checks |
| **Cloud Map** | CreateHttpNamespace, CreatePrivateDnsNamespace, CreatePublicDnsNamespace, GetNamespace, ListNamespaces, DeleteNamespace, UpdateHttpNamespace, UpdatePrivateDnsNamespace, UpdatePublicDnsNamespace, CreateService, GetService, ListServices, DeleteService, UpdateService, RegisterInstance, DeregisterInstance, DiscoverInstances, DiscoverInstancesRevision, ListInstances, GetInstancesHealthStatus, UpdateInstanceCustomHealthStatus, GetServiceAttributes, UpdateServiceAttributes, DeleteServiceAttributes, GetOperation, ListOperations, TagResource, UntagResource, ListTagsForResource | DNS namespaces create Route53 hosted zones; operation tracking; Terraform `aws_service_discovery_*` compatible |
diff --git a/ministack/services/cognito.py b/ministack/services/cognito.py
index 5365dc58..f58c3372 100644
--- a/ministack/services/cognito.py
+++ b/ministack/services/cognito.py
@@ -3127,14 +3127,33 @@ def _admin_list_groups_for_user(data):
def _admin_list_user_auth_events(data):
+ """List a user's auth events, gated on user-pool add-ons as real Cognito is.
+
+ Auth events are never recorded here (there is no event store), so a pool
+ with add-ons enabled always answers an empty list. A pool without add-ons
+ (AdvancedSecurityMode OFF or UserPoolAddOns absent) is refused with
+ UserPoolAddOnNotEnabledException. The add-on gate fires before the user is
+ resolved — measured against the live service (2026-08-26): an unknown user
+ in a pool without add-ons gets the add-on error, not UserNotFound.
+ """
pid = data.get("UserPoolId")
pool, err = _resolve_pool(pid)
if err:
return err
+ if (pool.get("UserPoolAddOns") or {}).get("AdvancedSecurityMode", "OFF") == "OFF":
+ return error_response_json(
+ "UserPoolAddOnNotEnabledException",
+ "This is an add on feature. Please update AdvancedSecurityMode"
+ " for your user pool to access this API.",
+ 400,
+ )
username = data.get("Username")
- _, err = _resolve_user(pool, username)
- if err:
- return err
+ user, _ = _resolve_user(pool, username)
+ if user is None:
+ # Real AWS answers this op with the plain message, without the name.
+ return error_response_json(
+ "UserNotFoundException", "User does not exist.", 400,
+ )
return json_response({"AuthEvents": []})
diff --git a/tests/test_cognito.py b/tests/test_cognito.py
index 1cb6d91f..220207ce 100644
--- a/tests/test_cognito.py
+++ b/tests/test_cognito.py
@@ -446,6 +446,55 @@ def test_cognito_admin_add_remove_user_from_group(cognito_idp):
members = cognito_idp.list_users_in_group(UserPoolId=pid, GroupName="editors")["Users"]
assert not any(u["Username"] == "liam" for u in members)
+def test_cognito_admin_list_user_auth_events_requires_addons(cognito_idp):
+ addon_msg = (
+ "This is an add on feature. Please update AdvancedSecurityMode"
+ " for your user pool to access this API."
+ )
+
+ pid = cognito_idp.create_user_pool(PoolName="AuthEventsPlainPool")["UserPool"]["Id"]
+ cognito_idp.admin_create_user(UserPoolId=pid, Username="mona")
+ with pytest.raises(ClientError) as exc:
+ cognito_idp.admin_list_user_auth_events(UserPoolId=pid, Username="mona")
+ assert exc.value.response["Error"]["Code"] == "UserPoolAddOnNotEnabledException"
+ assert exc.value.response["Error"]["Message"] == addon_msg
+
+ # The add-on gate fires before user resolution: an unknown user in a pool
+ # without add-ons still gets the add-on error, not UserNotFound.
+ with pytest.raises(ClientError) as exc:
+ cognito_idp.admin_list_user_auth_events(UserPoolId=pid, Username="ghost")
+ assert exc.value.response["Error"]["Code"] == "UserPoolAddOnNotEnabledException"
+
+ pid = cognito_idp.create_user_pool(
+ PoolName="AuthEventsOffPool",
+ UserPoolAddOns={"AdvancedSecurityMode": "OFF"},
+ )["UserPool"]["Id"]
+ cognito_idp.admin_create_user(UserPoolId=pid, Username="olga")
+ with pytest.raises(ClientError) as exc:
+ cognito_idp.admin_list_user_auth_events(UserPoolId=pid, Username="olga")
+ assert exc.value.response["Error"]["Code"] == "UserPoolAddOnNotEnabledException"
+
+ pid = cognito_idp.create_user_pool(
+ PoolName="AuthEventsAuditPool",
+ UserPoolAddOns={"AdvancedSecurityMode": "AUDIT"},
+ )["UserPool"]["Id"]
+ cognito_idp.admin_create_user(UserPoolId=pid, Username="axel")
+ resp = cognito_idp.admin_list_user_auth_events(UserPoolId=pid, Username="axel")
+ assert resp["AuthEvents"] == []
+
+ pid = cognito_idp.create_user_pool(
+ PoolName="AuthEventsAddonsPool",
+ UserPoolAddOns={"AdvancedSecurityMode": "ENFORCED"},
+ )["UserPool"]["Id"]
+ cognito_idp.admin_create_user(UserPoolId=pid, Username="nils")
+ resp = cognito_idp.admin_list_user_auth_events(UserPoolId=pid, Username="nils")
+ assert resp["AuthEvents"] == []
+
+ with pytest.raises(ClientError) as exc:
+ cognito_idp.admin_list_user_auth_events(UserPoolId=pid, Username="ghost")
+ assert exc.value.response["Error"]["Code"] == "UserNotFoundException"
+ assert exc.value.response["Error"]["Message"] == "User does not exist."
+
def test_cognito_domain_crud(cognito_idp):
pid = cognito_idp.create_user_pool(PoolName="DomainPool")["UserPool"]["Id"]
resp = cognito_idp.create_user_pool_domain(UserPoolId=pid, Domain="my-test-domain")